Counting objects in an binary image of olympic logo

I try lot of algo and matlab code to count the object in olympic logo i should get 5 object but my count only one how i should count an binary image of olympic logo and get 5 object need code

 Accepted Answer

Try this (untested):
% Convert the image from rgb into hsv color space:
hsvImage = rgb2hsv(rgbImage);
% Extract the hue image
h = hsvImage(:,:,1);
% Get the histogram
counts = histcounts(h, 1000);
% Find peaks in the histogram
[peaks, indexes] = findpeaks(counts);
% count the number of peaks
numberOfHues = length(peaks)
Requires Image Processing Toolbox for rgb2hsv() and Signal Processing Toolbox for findpeaks().

2 Comments

did not work it give me numberOfHues =1 i want to give 5 objects
louna, read this, then upload your image. Until then I can't help you because you've not given me anything to help you.

Sign in to comment.

More Answers (3)

sorry for that
i have this image
im searching for algorithm matlab code or matlab function to count objects in this image the function should tell me that there is 5 objects thank you
That is not the Olympic logo - where are the colors? You didn't say that you had a binary image . In that image there are 10 white objects and one black object.
If you want to find circles, I suggest you use imfindcircle(). See Brett Shoelson's circle finder app: http://www.mathworks.com/matlabcentral/fileexchange/34365-circle-finder

6 Comments

i wrote in title binary image I m new to matlab and its homework The question is Olympics logo consists of five circles intersecting with each other (cross five continents), the required algorithm here it can distinguish between them and say here there five objects(and by object mean circle ) the doctor said search in internet it's easy function hope Brett Shoelson's circle finder will work thank you again
OK, you're right - I must have though you meant binary like it was a digital image rather than pure black and white. I'm glad I was able to direct you to the right function, imfindcircle(), and Brett's demo of it, and you've now got it solved.
the function (imfindcircle())didnot work i need function can Detect intersecting Objects (not only circles) any help?
No, there is no general solution for that. Any arbitrarily-shaped object can be thought of as a superposition of smaller, overlapping objects.
imfindcircle() should have worked to find the big circles in your Olympic logo. It will not find overlapping objects - whatever those might be (is that like the quadrilaterals where the circles cross each other???).
Please show your script, and show what it gave you, and show me what you'd like to achieve.
i have the question to find algorithm that can count intersecting and overlapping objects in the binary image
*olympic logo image was example and he could give me image with intersecting squirrels and the algorithm should count the object
i tried function like normxcorr2 ,bwboundaries but didnot work the doctor said i should find function can say if there are intersecting Objects in the image
There is no such function. normxcorr2() finds a pattern in an image. There are others that can find objects that are rotated or scaled, such as this one using Hu's moments https://www.youtube.com/watch?v=Nc06tlZAv_Q
But unless you simplify the problem there is no general solution to do what you ask. Let's say I have a silhouette of a big coin. Underneath it are smaller coins. But they are not seen in the silhouette since the coin on top is much bigger. Can you detect how many small coins there are, and where they are? No, you cannot. Let's say you have a dash and the letter I such that the dash overlaps the bottom of the I to form an L shape. Can you detect that? What makes you think it's two bars and not an L shape? Like I said initially any blob could be the superposition of other blobs.

Sign in to comment.

Rahul punk
Rahul punk on 27 Dec 2018
Edited: Image Analyst on 27 Dec 2018
Hi.
  1. Please verify the image size is like 640*480.
  2. Then count pixel number of all black circle pixels in the whole image is 307200
  3. Then find the number of pixels in a single circle.
  4. After finding number of pixels in a single circle, then divide whole image value by the count in a single olympic circle pixel area to get the number of rings.
Easy
Thank you!
This is last and final solutions to find overlapping image analysis.

Community Treasure Hunt

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

Start Hunting!