- Make an interactive tool to adjust "gray" threshold (e.g. slider)
- Add an input control to ask for eccentricity threshold
- Allow the user to select the desired "circle" (add 'HitTest', 'on', and 'ButtonDownFcn' callback in the text call. See text and Text Properties)
- Automatically dismiss the perfect circle (the big one -your lenses) that will be the one with the minimum of your eccentricity values (closest to zero)
Need to find centre of the circle
7 ビュー (過去 30 日間)
古いコメントを表示
Need to find Centre of the black (approx) circle in the image. Please help.
0 件のコメント
回答 (3 件)
Frank Macias-Escriva
2017 年 3 月 2 日
Try this code in order to find the center of your "circle"
% some constants for "circle" detection
GRAY_TH = 128; % gray threshold
ECCENTRICITY_TH = 0.5; % eccentricity threshold, from 0(=>circle) to 1(=>line)
% load and convert to a binary image
entropy_img = imread('entropyfilt_imgB.jpg');
bw_entropy_img = entropy_img < GRAY_TH;
imshow(bw_entropy_img); hold on;
% look for region properties
s = regionprops(bw_entropy_img, entropy_img, {'Eccentricity', 'Centroid'});
% keep and plot those close to be a "circle"
numRegions = numel(s);
for k = 1:numRegions
if s(k).Eccentricity < ECCENTRICITY_TH
px = s(k).Centroid(1);
py = s(k).Centroid(2);
ptxt = [' \leftarrow(' num2str(px) ', ' num2str(py) ')'];
text(px, py, ptxt, 'Background', [.5 .5 .5], 'Color', 'blue');
plot(px, py, 'wd', 'MarkerFaceColor', 'blue');
end
end
Of course, you can enhance this piece of code in many ways:
Hope this help.
0 件のコメント
Walter Roberson
2017 年 3 月 1 日
Invert your image so the circle is white. imclearborder (or whatever it is called) to clear the white pixels that would introduce at the outside edge. regionprops asking for area and centroid and take the one with the larger area
0 件のコメント
Image Analyst
2017 年 3 月 1 日
Invert the image, histogram it and find a good threshold, then threshold to find a binary image. Call imclearborder() and bwareafilt(). Then follow the steps in my Image Segmentation Tutorial http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 where I find the centroids of blobs - just what you want to do.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Image Segmentation and Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!