Prev: function, textbox
Next: Eye Tracking
From: Divya Varma on 30 Jun 2010 07:13 Hi, Thank you for all of you in advance. I am trying to find an object from connected components found using bwconncomp of an image. What I followed was as follows: Image -> edge() -> bwconncomp -> regionprops() to find centroid and area. Filter connected components based on area and distance between centroids. Now suppose, i have 4 connected components in different shapes which form part of one object which I need, how can i find a bounding box covering all the four components? How I can find the bounding box coordinates so that it covers the object of interest? How i can find (x,y) pixel coordinates of each connected component found through bwconncomp()? Thanks, Divya
From: Image Analyst on 30 Jun 2010 07:34 You could call bwlabel() and regionprops() and then use the max() and min() functions on the PixelIdxList property - that's one way.
From: Ashish Uthama on 30 Jun 2010 07:40 On Wed, 30 Jun 2010 07:13:04 -0400, Divya Varma <divyar.varma(a)hcl.in> wrote: > Hi, Thank you for all of you in advance. I am trying to find an object > from connected components found using bwconncomp of an image. What I > followed was as follows: Image -> edge() -> bwconncomp -> regionprops() > to find centroid and area. Filter connected components based on area and > distance between centroids. Now suppose, i have 4 connected components > in different shapes which form part of one object which I need, how can > i find a bounding box covering all the four components? How I can find > the bounding box coordinates so that it covers the object of interest? > > How i can find (x,y) pixel coordinates of each connected component found > through bwconncomp()? > > Thanks, Divya REGIONPROPS will return a bounding box parameter for each of the connected component. This parameter has the upper left corner and the width of the box along x and y directions. Use MIN on the upper left coordinates to obtain the common ul corner. Add the width to each of the ul coordinates to obtain the lower left bound, use MAX on all values to obtain the common lower left. BW = imread('text.png'); s = regionprops(BW); centroids = cat(1, s.Centroid); imshow(BW) hold on %20 to 25 bbs = cat(1, s(20:25).BoundingBox); %Mark the individual letters used plot(centroids(20:25,1), centroids(20:25,2), 'r*') %First two columns are the coordinates of the upper left corner commonUL = min(bbs(:,1:2)); lowerRights = bbs(:,1:2) + bbs(:,3:4); commonLR = max(lowerRights); commonWidth = commonLR - commonUL; imrect(gca, [commonUL commonWidth]); %plot it hold off Also look at the PixelList and PixelIdxList parameter returned by REGIONPROPS.
From: Divya Varma on 30 Jun 2010 08:16 Thank you so much for your quick response. Surely this line of thought would help me in solving the problem. Thanks, Divya
|
Pages: 1 Prev: function, textbox Next: Eye Tracking |