counting the number of objects

I have an brain image and there are three overlapped objects.The overlapped object is nails ..can i count these overlapped objects.in medical images

9 Comments

@Pat: This is your 108th question. It is time to include the required details to make it easy to answer.
http://www.mathworks.com/matlabcentral/answers/7924-where-can-i-upload-images-and-files-for-use-on-matlab-answers
I have uploaded my image
http://imgur.com/n7vGa
Hello, Pat.
You said that the three nails were overlapped.
But, I have seen your uploaded image,
and they aren't overlapped each other.
THE nails are overlapped on brain image ,,not on each other,is it possible to count these nails
What other image? You gave the non-overlapped image only, for some reason. Why did you even give that image at all (the solution is trivial)? When you are going to post the overlapped one?
only that image was given to me ,,,thats y i had posted it...
may i know what u mean by
No need - the patient is dead! ;-)
If I had three nails embedded in my brain, most likely I would be dead, and a physician could instantly see how many nails had killed me, and wouldn't need an image processing program to count them. So why did you ask about overlapping nails when that's not what you have?
Hahaha :D
I Agree with U

Sign in to comment.

 Accepted Answer

Hello, Pat.
It is possible to count the nails.
You just need to perform some morphologichal operations, such as
erosion, area open, etc.
Then, in the next step you need to count the objects. You can use regionsprops command.
Here my demo :
Irgb = imread('n7vGa.jpg');
Igray = rgb2gray(Irgb);
Ibw = im2bw(Igray, 0.9);
se = strel('square',2);
Imorph = imerode(Ibw,se);
Iarea = bwareaopen(Imorph,130);
Idiff = Imorph - Iarea;
Ifinal = bwareaopen(Idiff,70);
stat = regionprops(Ifinal,'BoundingBox');
str = sprintf('number of detected nails : %d', length(stat));
imshow(Irgb); title(str); hold on;
for cnt = 1 : length(stat)
bb = stat(cnt).BoundingBox;
rectangle('position',bb,'edgecolor',rand(1,3));
end
And the result :
Is that you meant??

12 Comments

Thanks chandra
Chandra please look at this
http://imgur.com/HALTv
even when there is a round object it is not detecting
So, you need to apply a little different techniques.
Just try to modify my code.
Try to apply another morphologichal operations.
If you still difficult to understand that,
Then show me your original image.
chandra the same code cannot be applied for different images
http://imgur.com/jlnuV
in this at centre there are 4 overlapped parts ehich are brighter in colour ,,,,
As long as the background image is same, you don't need to modify
your code.
Please upload the original version of http://imgur.com/HALTv
I'll try to find what's wrong with my code.
Chandra the original version is which i sent u first with 3 nails
i need some more objects as i was told by my guide,so i modified it , i need 5 objects ,so i modified like that
Now, What can I do to help you solve your problem?
I think my code will also works on image 'http://imgur.com/HALTv'.
Coz, the missed object in this image (that contains 5 objects) is detected in previous image (that contains 3 object).
It detected only 4 objects
Finally, I found the mistake.
The background image that you used are not same.
Check it carefully! The second one is lighter.
Now, just modify line
Ifinal = bwareaopen(Idiff,70);
with
Ifinal = bwareaopen(Idiff,63);
It works on both.
If in the future it doesn't work again,
Just try to setting the value like I did.
I hope this helps you.
No need - the patient is dead! ;-)
Thank u chandra

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 26 Dec 2011
Probably . . . as long as they're not 100% overlapped and you can come up with some algorithm for separating them.

1 Comment

I have uploaded my image
http://imgur.com/n7vGa

Sign in to comment.

Categories

Community Treasure Hunt

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

Start Hunting!