如何绘制从一个图像获得的轮廓在另一个图像上的轮廓?将从一个图像获得的轮廓绘制在另一个图像上
我的original
图像和changes
图像大小相同,但changes
只有部分original
的一部分。我想这些部分得到强调色original
我有相同的Python代码:
original = cv2.imread(image1_path) #this should be background
changes = cv2.imread(image2_path) #contours found from this should come over original
ret,thresh = cv2.threshold(changes,127,255,0)
image, contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,
cv2.CHAIN_APPROX_SIMPLE)
img = cv2.drawContours(original, contours, -1,(0,0,255), 2)
如何做同样的在Matlab?
编辑
changes = imread('changes.jpg');
original = imread('original.jpg')
c = edge(changes,'canny');
original(:,:,1) = original;
original(:,:,2) = original(:,:,1);
original(:,:,3) = original(:,:,1);
imshow(original+repmat(uint8(c),[1,1,3])*255);
几个问题: 1.你需要从Matlab调用OpenCV还是只需要功能等价的? 2.结果与OpenCV结果的匹配程度(即轮廓搜索算法 - 是否必须精确?) 3.您能否使用MATLAB-Python桥接器(例如[matpy](http:// algoholic.eu/matpy/))使用MATLAB数据在MATLAB中从字面上调用相同的Python代码? – ALGOholic
@ALGOholic 1.我非常想拥有功能等值。精确度不是问题(截至目前)。 3.我不知道该怎么做,但现在你已经提到了,我会研究它。那么,Matlab是否具有我想要的功能? – Nancy
我忘了问第四个问题 - 您是否有MATLAB中的图像处理工具箱?例如imcontour()和edge()。你可以做的一个方法是:im = imread('braincube.png'); C =边缘(rgb2gray(IM), '精明'); imshow(im + repmat(uint8(c),[1,1,3])* 255)其中braincube.png是RGB图像,如果是灰度图,则可以跳过rgb2gray()和repmat()。如果您需要阈值,则可以将im> 127放在边缘(rgb2gray(im)> 127,'canny'); – ALGOholic