在roi上执行边缘检测

时间:2018-05-23 07:12:59

标签: matlab image-processing edge-detection roi

eight.jpg 我使用matlab eight.tif

中的八个图像

我有以下代码:

FullImage = imread('eight.tif');
roi_col = [50 50 250 250];
roi_row = [200 50 50 200];
ROI_help1 = roipoly(FullImage,roi_col,roi_row);
roi_col = [100 70 200 200];
roi_row = [180 100 70 180];
ROI_help2 = roipoly(FullImage,roi_col,roi_row);
ROI=logical(ROI_help2-ROI_help1);
YourFilter = @(x) edge(FullImage,'Canny',0.1);
J = roifilt2(FullImage,ROI,YourFilter);
figure, imshow(FullImage)
overlay=imoverlay(FullImage,J,'red');
hold on;
imshow(overlay);

这给了我这个: edge detection performed with canny on roi

如何仅在圆圈上执行精确边缘检测,保持内部和外部红色区域不变,那么它应该在那里显示正常图像?

1 个答案:

答案 0 :(得分:0)

解决了我的问题。 只需要创建一个ROI补充和减去J

ROI_neg=imcomplement(ROI);
LOL=J-ROI_neg;
figure;
overlay=imoverlay(Image,LOL,'red');
hold on;
imshow(overlay);

但是,如果我使用不同的图像(拼接图像,太大而无法更新),它将无法工作。我缺少任何具体要求吗?数据类型等?我用.tif

相关问题