The exact difference between background and foreground

Hi all I want to obtain background and foreground difference exactly. From shown image you see i wnat to get from images the all particles like figure. The original image like this and i write this code but it doesnt work fine. What is your suggestions new filter design or something helpful. Because after this process i want to take circular(nearly) particles from these images(maybe tolerance band). Here is the starting code for background foreground difference
% imshow(c8);
I=c7(1:420, 1:712);
subplot(2,2,1);
imshow(I(1:420, 1:712));
Iblur1 = imgaussfilt(I,1);
subplot(2,2,2);
imshow(Iblur1);
background = imopen(Iblur1,strel('disk',3));
I2 = I - background;
subplot(2,2,3);
imshow(I2);
I3 = imadjust(I2);
subplot(2,2,4);
imshow(I3);
The original image untitled one, and after background foreground particle exact definition i want to find these high circularity particles.

 採用された回答

Walter Roberson
Walter Roberson 2016 年 4 月 22 日

1 投票

The difference between foreground and background is intent.
For example, if you are studying the Sun, then anything other than the Sun in your image is of no interest: the Sun is the foreground. But if you are studying solar comets, then you want to ignore the Sun and look at the little dots flying very close to the Sun: the comets are the foreground and the Sun is the background. In exactly the same picture.

その他の回答 (2 件)

Image Analyst
Image Analyst 2016 年 4 月 22 日

1 投票

It looks like you can threshold either the original image and/or an image you get from stdfilt().
Then ask for the area and perimeter and compute the circularity = 4*pi*area/perimeter^2. Look for blobs where the circularity is high, say more than 0.7 or so.
See my Image Segmentation Tutorial for more help: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862

8 件のコメント

ali
ali 2016 年 4 月 23 日
編集済み: ali 2016 年 4 月 24 日
And original image stdfilt is white all newone=stdfilt(original);//is it wrong to use it
Image Analyst
Image Analyst 2016 年 4 月 24 日
Try casting original to double(), though I don't think it should be necessary. Then display with [] in imshow():
newone = stdfilt(double(original));
imshow(newone, []);
ali
ali 2016 年 4 月 24 日
And this is the just on threshold level, I think before all this there should be good level filter and you see thresholding not good just to this step.
Image Analyst
Image Analyst 2016 年 4 月 24 日
Yes, you undoubtedly have problems. Not only is there extremely low contrast with respect to the noise, but your blobs are pretty much all connected together. After noise reduction and thresholding, you may need watershed. See Steve's blog: http://blogs.mathworks.com/steve/2013/11/19/watershed-transform-question-from-tech-support/
ali
ali 2016 年 4 月 24 日
編集済み: Walter Roberson 2016 年 4 月 25 日
YOur codes revised like that (applied to gaussian filter)
originalImage =c7(1:420, 1:712);
G = fspecial('gaussian',[3 3],2);
originalImage = imfilter(originalImage,G);
and also threshold for the first level is like that
thresholdValue = 117;
An then for find circles maybe convert after this. And also some erosion or dilation after conversion
What is your suggestions
Image Analyst
Image Analyst 2016 年 4 月 24 日
After you split apart with watershed (like Steve's blog in the link I just gave in my last comment shows), then compute the area and perimeter and possibly solidity with regionprops(). Then compute the circularity and see which particles are circular or convex enough for you to consider that they're "circles."
ali
ali 2016 年 4 月 25 日
編集済み: ali 2016 年 4 月 25 日
Thanks for all Im going to develop step by step first stdfilt with double comes result like this. When I m writing these ı havent finished yet. So there should be another process for define threshold level after stdfilt( ı choose there 11, but it breaks out the image not good) When I finished others I will give info to you thanks so much.
Image Analyst
Image Analyst 2016 年 4 月 26 日
I'm sorry that this project would take me more than the few minutes I'm able to donate to questions. I'm not even sure what you want, and if what you say you want is really what you need. I'd need to devote a ton more time into figuring that out and developing an algorithm for it and I just can't spend that much time. This is what I do all day at work for my own projects and so I have very little time for others - usually just a few minutes per question. Good luck though.

サインインしてコメントする。

ali
ali 2016 年 4 月 25 日

0 投票

Thanks for suggest i implemented all your comments and results. Comparing the original what should i do to take better results. I also tried and integrated watershed code there.

質問済み:

ali
2016 年 4 月 22 日

コメント済み:

2016 年 4 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by