From: Vivian Harvey on
"David Young" <d.s.young.notthisbit(a)sussex.ac.uk> wrote in message <hnoqdh$hq8$1(a)fred.mathworks.com>...
> OK, now I've seen the image, maybe it's easier than I thought and doesn't need a Hough transform. If all the images have shapes that are nicely joined up like those in the test image, and they don't overlap, then you can just do a connected region analysis to separate them out and use simple properties of the regions to distinguish the more circular ones from the others.
>
> Here's some example code that works on the image your link points to, assuming it's been saved in shapes.png:
> -----
> im = imread('../shapes.png');
> im = rgb2gray(im);
>
> % find the centroids of low-eccentricity blobs
> graythresh = 128;
> eccthresh = 0.6;
> props = regionprops(im < graythresh, 'Centroid', 'Eccentricity');
> roundones = props([props.Eccentricity] < eccthresh);
> centroids = [roundones.Centroid];
>
> % show them
> imshow(im);
> hold on;
> plot(centroids(1:2:end), centroids(2:2:end), 'g+');
> hold off;
> -----
> This just uses the eccentricity to pick out the rounder shapes. It's got a couple of parameters that are set at the start; these might need to be tweaked for this to work across a range of examples, and you might need a more sophisticated test in general. Look at regionprops for inspiration!

Thank you very much for the above, I will use the shorter one (this one first) and for a tweaking part the next post :) ..Regards
From: Vivian Harvey on
Hi

It took a while but I filtered out what I needed (It is now a program of around 20 lines) and just want to thank you again.

Regards,
Vivian
First  |  Prev  | 
Pages: 1 2 3
Prev: create a vector of months
Next: fmincon minimisation