Is there a way to detect circles with radii smaller than 10 pixels?

I am trying to look for small, red dots in an image, but the dots are usually less than 10 pixels large. imfindcircles finds every circle but the ones I am looking for, including a lot of phantom circles. Is there any way to accurately detect these circles?

 Accepted Answer

Simply use color segmentation. I have several demos in my File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862

8 Comments

Thanks! By the way, is there any way to do this without having the user draw on the file?
Yes. Use the color segmentation methods in my File Exchange. For example the one in RGB space does not require the user to draw the regions on the image.
I tried to run your program after downloading it, but before the thresholds are computed, the program give the error message that the image exceeds the matrix dimensions. Do you know why this might be the case?
All of the demos work. You probably modified it somehow. Please attach the code that you are running that gives the error.
The code gave the error message before this was run.
% Assign the low and high thresholds for each color band. if strcmpi(reply2, 'My Own') strcmpi(selectedImage, 'Canoe') > 0 % Take a guess at the values that might work for the user's image. redThresholdLow = graythresh(redBand); redThresholdHigh = 255; greenThresholdLow = 0; greenThresholdHigh = graythresh(greenBand); blueThresholdLow = 0; blueThresholdHigh = graythresh(blueBand); if eightBit redThresholdLow = uint8(redThresholdLow * 255); greenThresholdHigh = uint8(greenThresholdHigh * 255); blueThresholdHigh = uint8(blueThresholdHigh * 255); end else % Use values that I know work for the onions and peppers demo images. redThresholdLow = 85; redThresholdHigh = 255; greenThresholdLow = 0; greenThresholdHigh = 70; blueThresholdLow = 0; blueThresholdHigh = 90; end
Then it's not useful. Code that occurs after the error is not helpful in figuring out what the error is. I need to know what code you ran before this that gave the error. Or what the name of the demo you download and ran was. Or at least give the actual error message. You gotta give me something to go on here!
Sorry about that! I downloaded the SimpleColorDetection file and ran it without any modifications. Here is the code that ran right before the error-
% Plot all 3 histograms in one plot. subplot(3, 4, 5); plot(grayLevelsR, countsR, 'r', 'LineWidth', 2); grid on; xlabel('Gray Levels'); ylabel('Pixel Count'); hold on; plot(grayLevelsG, countsG, 'g', 'LineWidth', 2); plot(grayLevelsB, countsB, 'b', 'LineWidth', 2); title('Histogram of All Bands', 'FontSize', fontSize); maxGrayLevel = max([maxGLValueR, maxGLValueG, maxGLValueB]); % Trim x-axis to just the max gray level on the bright end. if eightBit xlim([0 255]); else xlim([0 maxGrayLevel]); end
% Now select thresholds for the 3 color bands. message = sprintf('Now we will select some color threshold ranges\nand display them over the histograms.'); reply = questdlg(message, 'Continue with Demo?', 'OK','Cancel', 'OK'); if strcmpi(reply, 'Cancel') % User canceled so exit. return; end
Right after this piece of code, the program gave the error that the image exceeds the matrix dimensions.
I ran it for each of the 3 demo images and it worked flawlessly. What image did you use? I even said to use it on one of my own (attached) and that also worked. I'm sorry I can't reproduce your error. You'll either have to post the image you used or put in some debugging statements.

Sign in to comment.

More Answers (0)

Asked:

AG
on 9 Nov 2015

Commented:

on 14 Nov 2015

Community Treasure Hunt

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

Start Hunting!