【发布时间】:2013-12-04 03:15:50
【问题描述】:
我有一张包含两条轮廓线的图像。我想在这些轮廓线内填充不同的颜色。如何实施?这是我绘制两条等高线的代码
function FillColorContour(Img,phi1,phi2,color1,color2)
imagesc(uint8(Img),[0 255]),colormap(gray),axis off;axis equal,title('FillColorContour')
hold on,[c,h1] = contour(phi1,[0 0],'r','linewidth',1); hold off
hold on,[c,h2] = contour(phi2,[0 0],'r','linewidth',1); hold off
end
使用它。我会通过命令调用:
Img=imread('peppers.png');
[Height Wide] = size(Img);
[xx yy] = meshgrid(1:Wide,1:Height);
phi1 = (sqrt(((xx - 60).^2 + (yy - 100).^2 )) - 15);
phi2 = (sqrt(((xx - 100).^2 + (yy - 150).^2 )) - 15);
FillColorContour(Img,phi1,phi2,'r','b') %Assume'r' is red, 'b' is blue
这是在https://www.dropbox.com/s/ll4npg3cmturt4c/contourex.PNG 之前 这是运行后https://www.dropbox.com/s/pqi4rxluxfegxhn/contourexfill.png
【问题讨论】:
-
请展示您拥有的和想要获得的示例图。你已经看过 `contourf` 了?
-
我更新了我需要的内容。请检查
-
+1 用于使用 Matlab 附带的示例图像! :-)
-
您确定需要填充轮廓吗?您使用的那些轮廓只是圆形,所以也许您需要一个圆形填充功能?
-
@A. Donda:我的轮廓是任何轮廓,这意味着它可以是圆形,方形......在我的问题中。我只提出简单的问题以便于理解。我想在轮廓内填充颜色。谢谢
标签: matlab