Is there a way to detect circles with radii smaller than 10 pixels?
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
0 votes
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
Image Analyst
on 9 Nov 2015
Simply use color segmentation. I have several demos in my File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
8 Comments
AG
on 9 Nov 2015
Thanks! By the way, is there any way to do this without having the user draw on the file?
Image Analyst
on 9 Nov 2015
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.
AG
on 11 Nov 2015
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?
Image Analyst
on 11 Nov 2015
All of the demos work. You probably modified it somehow. Please attach the code that you are running that gives the error.
AG
on 11 Nov 2015
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
Image Analyst
on 12 Nov 2015
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!
AG
on 14 Nov 2015
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.
Image Analyst
on 14 Nov 2015
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.

More Answers (0)
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Products
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)