![]() |
【求助】关于Demos里的一个程序!
Image Processing Toolbox Demos里面的Measuring Image Features里的例子Measuring the Radius of a Role of Tape的程序有一处看不太明白,程序如下:
RGB = imread('tape.png'); imshow(RGB); text(15,15,'Estimate radius of the roll of tape',... 'FontWeight','bold','Color','y'); I = rgb2gray(RGB); threshold = graythresh(I); BW = im2bw(I,threshold); imshow(BW); dim = size(BW); [COLOR="Blue"]col = round(dim(2)/2)-90;---?此处为什么要减90?什么意思啊?[/COLOR] row = min(find(BW(:,col))); [COLOR="blue"]connectivity = 8; num_points = 180;-[/COLOR]---?此两处的赋值为什么是8和180?可以是别的吗? contour = bwtraceboundary(BW, [row, col], 'N', connectivity, num_points); imshow(RGB); [COLOR="blue"]hold on[/COLOR];----?hold on 什么意思? plot(contour(:,2),contour(:,1),'g','LineWidth',2); x = contour(:,2); y = contour(:,1); % solve for parameters a, b, and c in the least-squares sense by % using the backslash operator abc=[x y ones(length(x),1)]\[-(x.^2+y.^2)]; a = abc(1); b = abc(2); c = abc(3); % calculate the location of the center and the radius xc = -a/2; yc = -b/2; radius = sqrt((xc^2+yc^2)-c) % display the calculated center plot(xc,yc,'yx','LineWidth',2); % plot the entire circle theta = 0:0.01:2*pi; % use parametric representation of the circle to obtain coordinates % of points on the circle Xfit = radius*cos(theta) + xc; Yfit = radius*sin(theta) + yc; plot(Xfit, Yfit); message = sprintf('The estimated radius is %2.3f pixels', radius); text(15,15,message,'Color','y','FontWeight','bold'); 谢谢先! |
所有时间均为北京时间。现在的时间是 08:08。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.