0

I am new to MATLAB Image Processing. I am writing a code to detect some irregular circles, remove the remaining noise from the Image and find the center mean point of the irregular Black circles (ellipse). Here is the Image

[IMG]http://i61.tinypic.com/14y8p4x.jpg[/IMG]

This is the code I have written so far

m = imread('cbnimg.jpg');
imshow(m)
im = mean(m,3);
im = (im-min(im(:))) / (max(im(:))-min(im(:)));
figure; 
imshow(im,[]);
impixelinfo
figure;

bin = im2bw(im);
imshow(bin);
figure;
bin = edge(bin);
SE = strel('disk',2);
cir =~imdilate(bin,SE);
imshow(cir);

Here is the result image of this code

[IMG]http://i61.tinypic.com/30n9egn.png[/IMG]

I want to detect only the black spots (Irregular Cicrcle) and remove the remaining noise from the picture as I want the Center Mean Point of these Black irregular Circles..

Can anyone suggest me some algorithms or techniques to get my center mean point?

Thank You

Agror
  • 37
  • 9
  • 2
    Show us the code of what have you tried and what doesnt work as you wish – Ander Biguri Sep 29 '14 at 17:00
  • Hello Ander.. I am editing the code again n again but i still cannot detect the black spots. I used imfindcircles and varied the radius range but it is not detecting the spots. I normalized the image, did thresholdinig and used edge command but did not detect the spots. I need some algorithm to detect these irregular black spots.. Thank You – Agror Sep 29 '14 at 17:09
  • here are some starting points: http://stackoverflow.com/questions/21100541/make-a-mask-for-each-well-in-a-grid/21103573#21103573 , http://stackoverflow.com/questions/23999205/detect-black-dots-from-color-background/24005169#24005169 – bla Sep 29 '14 at 17:12
  • Hello. Again, show us your code. Even if we really try we can not read it from your computer. So please, Show us the code of what have you tried and what doesnt work as you wish – Ander Biguri Sep 29 '14 at 20:28
  • Hello Ander.. I wish I could make a prgram to read stuff from other's computers.. I have added the code of my task in the question.. Thank You – Agror Sep 30 '14 at 18:06
  • As far as I see you are doing binarization, then edge detection and then dilation. What I would try would be binarization, then erosion and then dilation again (this is called opening I think). Then, you can apply a labelling algorithm and retain the labels that are only "big enough" (each label contains at least n pixels). It is probably useful to erode and dilate more than 1 time. – Javi Sep 30 '14 at 18:28

1 Answers1

1

A very naïve approach: apply erosion twice and the dilation twice after a binarization:

m = imread('cbnimg.jpg');
imshow(m)
im = mean(m,3);
im = (im-min(im(:))) / (max(im(:))-min(im(:)));

bin = im2bw(im);
SE = strel('disk',10);
bin = ~imerode(~bin,SE);
bin = ~imerode(~bin,SE);

bin =~imdilate(~bin,SE);
bin =~imdilate(~bin,SE);
imshow(bin);

enter image description here

The shape of the circles is a bit changed, but the change in the center point should be really small. If you want something more ellaborated and robust, erode, label the elements in the image, divide them in two clusters depending on the mass (number of pixels) of each label (with k-means for instance) and then discard all the label correspoding to the cluster with lower masses.

However, for what you asked so far this should be enough.

Javi
  • 3,440
  • 5
  • 29
  • 43