From: Kenneth Galea on 24 Dec 2009 05:44 Hi everyone, i'm new to this forum and new to matlab hopefully somebody can help me out there:) I'm currently doing some image processing for vision base object handling in order to finally be able to control a robotic arm. I did thresholding (using Otsu's method), edge detection(using Zhang_Suen algorithm) some noise removal and labelling of different objects. Now my problem is that if I have 3 different objects in an image and I want to keep ONLY the OUTER perimiter of the 3 objects....how can I do it?? I am using regionprops in this manner big_area = max([stats.Area]) L = ismember(L, big_area) But it's obviously not working!! Also in this case command prompt will display only the maximum area which is not what I really need considering that I will have more than one object (all with different sizes). However I need to keep only there outer perimiter:/ Somebody can give me a clue of what can I do?? Thanks
From: ImageAnalyst on 24 Dec 2009 10:08 Well of course not. Looking at area won't give you the perimeter. There's a regionprops measurement for the LENGTH of the perimeter, and there's a function bwboundaries() that will give you the coordinates of the perimeters. Perhaps you'd like to look at this image analysis demo where I show how bwboundaries (and other functions) is used: http://www.mathworks.com/matlabcentral/fileexchange/25157 -ImageAnalyst
From: Kenneth Galea on 24 Dec 2009 11:01 ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <799ebc6d-1974-4019-90b6-97375b053c68(a)21g2000yqj.googlegroups.com>... > Well of course not. Looking at area won't give you the perimeter. > There's a regionprops measurement for the LENGTH of the perimeter, and > there's a function bwboundaries() that will give you the coordinates > of the perimeters. > Perhaps you'd like to look at this image analysis demo where I show > how bwboundaries (and other functions) is used: > http://www.mathworks.com/matlabcentral/fileexchange/25157 > -ImageAnalyst Thanks for your reply. I checked for length by typing stats = regionprops(L,'all') and there isn't any property referred to as 'Length'....maybe you mean Major/Minor AxisLength (but i think these are used for the ellipse)? I have matlab R2008b!! I did this code and it worked pretty well: [big_area] = max([stats.FilledArea]) select = find([stats.FilledArea] == big_area) L = ismember(L, select); RGB = label2rgb(L); %Display outer object figure imshow (RGB); For example a donut with outer and inner circles (when considering only edges), this would select only the outer circle which is what I need but again there will be more than 1 object in my image. However now I'll try to understand your code although its a bit difficult :/ Thanks again Kenneth
From: ImageAnalyst on 24 Dec 2009 12:59 Kenneth: Again you're working with area. If you want area, fine. But you first said that you wanted the outer perimeter. No I didn't mean MajorAxisLength. I said the "length of the perimeter" and it you examine the regionprops things you can ask for you will see that Perimeter is one of the things listed, but it is the "length" of the perimeter, not the "coordinates" of the perimeter that it gives you. That's why I said to use bwboundaries instead - it WILL give you the actual perimeter (its coordinates), not just it's length. If your objects have holes in them and you don't want the perimeters of the interior holes, then just fill your binary image with imfill() before calling either bwboundaries() or regionprops(). Finally, bwperim() is a function that may interest you (but I doubt it). Let me know what parts of my demo are difficult to understand - I can try to make the comments more verbose and explanatory. Regards, ImageAnalyst
From: Kenneth Galea on 24 Dec 2009 13:38
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <5588c2b2-4dd0-4583-bfa0-125efafc56c0(a)3g2000vbp.googlegroups.com>... > Kenneth: > Again you're working with area. If you want area, fine. But you > first said that you wanted the outer perimeter. No I didn't mean > MajorAxisLength. I said the "length of the perimeter" and it you > examine the regionprops things you can ask for you will see that > Perimeter is one of the things listed, but it is the "length" of the > perimeter, not the "coordinates" of the perimeter that it gives you. > That's why I said to use bwboundaries instead - it WILL give you the > actual perimeter (its coordinates), not just it's length. > > If your objects have holes in them and you don't want the perimeters > of the interior holes, then just fill your binary image with imfill() > before calling either bwboundaries() or regionprops(). > > Finally, bwperim() is a function that may interest you (but I doubt > it). > > Let me know what parts of my demo are difficult to understand - I can > try to make the comments more verbose and explanatory. > Regards, > ImageAnalyst Sorry to ask but I'm really new here and I need to attach an image in order to explain myself better. Is there a way to make this? Thanks |