Differentiating Between Different Coloured Objects

2 views (last 30 days)
Hi, I am a physics student conducting an experiment that is focused on how beaded chains interact with each other when they are shaken. Without going into to much detail I have a plain brass chain and brass chain that has been oxidized to look a bit darker.
I need to be able to find the location of each bead and determine which chain it belongs to using Matlab to analyse pictures taken during the experiment.
You can see a sample picture here: http://i.imgur.com/mMNpc.jpg
I can use simple thresholding such as
pic = imread('IMG_0001.jpg');
pic = rgb2gray(im2double(pic));
thres = 0.94;
pic2 = pic(1125:2019,964:4264)>=thres;
pic2 = medfilt2(pic2, [8 8]);
to find the brighter undarkened beads easily (where I get something like http://i.imgur.com/jnGnn.jpg), but I am having trouble finding a way to reliably find the darker beads even though it they are obviously distinct from the brighter ones to the human eye.
I have tried double thresholding such as
for i = 1:q
for j = 1:w
if pic(i,j)>0.5 && pic(i,j)<0.9;
pic(i,j) = 1;
end
end
end
but it does not reliably work . I'm guessing the thresholding methods I am using are actually really crude so I figured I would ask if there are better functions or something I could be using. I am still pretty much a novice in Matlab.
Note: I need to write code that will analyse ~1000 pictures each time I want to do the experiment so maybe take that into consideration. Also, it doesn't need to find every bead 100% of the time, but as many as possible (and without including any of the beads from the other chain)

Answers (1)

Jeff E
Jeff E on 24 Feb 2012
There are quite a few RGB thresholding/segmentation algorithms in the File Exchange. However, just identifying the colors probably won't be enough on its own. I've looked at this image a bit, and there is quite a bit of overlap between the centers of the darker beads, and the edges of the lighter beads. A different approach might be to find local maximums of intensity, which should correspond with the centers of your beads, and then try to identify some statistic that separates bright from dark. I'm going to go out on a limb and say average intensity would be a decent place to start. ;) Take a look at imregionalmax, and Steve Eddins' blog series here: http://blogs.mathworks.com/steve/2009/04/24/continental-divide-1-intro/ and then ask more questions.

Categories

Find more on MATLAB Report Generator in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!