0
我想绘制二进制图像中的细胞周围的椭圆形状。到目前为止,我尝试了下面显示的代码在二进制图像中的单元格周围绘制椭圆。在代码中,IBord是二进制图像.Code在单元格周围绘制椭圆形状。如何在图像中围绕物体绘制椭圆形状
s = regionprops(IBord, 'Orientation', 'MajorAxisLength', 'MinorAxisLength', 'Eccentricity', 'Centroid');
figure(2);
imshow(IBord)
phi = linspace(0,2*pi,50);
cosphi = cos(phi);
sinphi = sin(phi);
for k = 1:length(s)
xbar = s(k).Centroid(1);
ybar = s(k).Centroid(2);
a = s(k).MajorAxisLength/2;
b = s(k).MinorAxisLength/2;
theta = pi*s(k).Orientation/180;
R = [ cos(theta) sin(theta)
-sin(theta) cos(theta)];
xy = [a*cosphi;b*sinphi];
xy = R*xy;
X = xy(1,:) + xbar;
Y = xy(2,:) + ybar;
plot(X,Y,'r','LineWidth',2);
end
好心建议我如何修改这个代码来绘制椭圆形(蛋状)周围细胞的二值图像。
尝试使用egg-functions,例如:http://www.mathematische-basteleien.de/eggcurves.htm或在这里:http://www.geocities.jp/nyjp07/Egg/index_egg_E。 html – Adiel