[求助]Demos里的一个例子。
各位gg,jj帮忙看看吧。郁闷老半天了,小女子在此先谢过啦。。。RGB = imread('tape.png');
imshow(RGB);
I = rgb2gray(RGB);
threshold = graythresh(I);
BW = im2bw(I,threshold);
imshow(BW);
dim = size(BW);
col = round(dim(2)/2)-90;---这里为什么要减90啊?
row = min(find(BW(:,col)));
connectivity = 8;
num_points = 180;
contour = bwtraceboundary(BW, [row, col], 'N', connectivity, num_points);--这句什么意思啊?
imshow(RGB);
hold on;
plot(contour(:,2),contour(:,1),'g','LineWidth',2);
x = contour(:,2);
y = contour(:,1);
abc=[x y ones(length(x),1)]\[-(x.^2+y.^2)];
a = abc(1); b = abc(2); c = abc(3);
xc = -a/2;
yc = -b/2;
radius = sqrt((xc^2+yc^2)-c)
plot(xc,yc,'yx','LineWidth',2);
theta = 0:0.01:2*pi;
Xfit = radius*cos(theta) + xc;
Yfit = radius*sin(theta) + yc;
plot(Xfit, Yfit);