how can i count the number of circles with random centers and fixed diameters.
    4 ビュー (過去 30 日間)
  
       古いコメントを表示
    
I want to get a plot of size of circles(pixels) vs. their numbers. Example 10 of 20 pixels, 15 of 10 pixels size etc.. the background should be contrast of intensity of the circles..
3 件のコメント
  Image Analyst
      
      
 2012 年 12 月 3 日
				Someone added this as a tag. It's not appropriate for a tag so I'm moving it here: http://www.mathworks.com/matlabcentral/answers/24609-counting-the-pixels-within-a-circle-detected-in-an-image
採用された回答
  Image Analyst
      
      
 2012 年 12 月 3 日
        
      編集済み: Image Analyst
      
      
 2012 年 12 月 4 日
  
      See my Image Segmentation Tutorial. It determines the size distribution of circles (coins).  http://www.mathworks.com/matlabcentral/fileexchange/25157-image-segmentation-tutorial-blobsdemo You just need to call bar() to display them.
You might also try imfindcircles() in the Image Processing Toolbox, or see Brett's demo:  http://www.mathworks.com/matlabcentral/fileexchange/34365-findcirclesgui
clc;    % Clear the command window.
close all;  % Close all figures (except those of imtool.)
clear;  % Erase all existing variables.
workspace;  % Make sure the workspace panel is showing.
format longg;
format compact;
fontSize = 20;
% Get centroid via bwboundaries and incorrect method.
rgbImage = imread('D:\Temporary stuff\welcome-green-circles-layout.jpg');
subplot(2, 2, 1);
imshow(rgbImage);
title('Original Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
% Get centroid correctly via regionprops
binaryImage = rgbImage(:,:,1) < 200;
subplot(2, 2, 2);
imshow(binaryImage);
title('Binary Image with Centroids', 'FontSize', fontSize);
hold on;
measurements = regionprops(binaryImage, 'Centroid', 'Area');
numberOfCircles = length(measurements);
allAreas = [measurements.Area]
for k = 1 : numberOfCircles
  centroid = [measurements(k).Centroid];
  xCenter = centroid(1);
  yCenter = centroid(2);
  plot(xCenter, yCenter, 'b+');
end
[counts values] = hist(allAreas);
subplot(2, 2, 3);
bar(values, counts);
grid on;
title('Histogram of Areas (the size distribution)', 'FontSize', fontSize);
message = sprintf('The number of circles is %d', numberOfCircles);
msgbox(message);
その他の回答 (0 件)
参考
カテゴリ
				Help Center および File Exchange で Image Processing Toolbox についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


