Canny边缘检测器正在检测图像的边界

时间:2017-07-15 11:47:32

标签: matlab canny-operator

SR_DynUeber_einfam[!SR_DynUeber_einfam$PID %in% NullNK,]

输入

enter image description here

预期结果

enter image description here

实际结果

enter image description here

在这里,我们看到Canny Edge Detector正在检测图像的边界线,这不是我预期的结果。

我如何实现这一目标?

源代码

clear_all();

image_name = 'canny_test.png';

% no of  pixels discarded on border areas
discard_pixels = 10;

% read image and convert to grayscale
input_image = gray_imread(image_name);

% discard border area
input_image = discard_image_area(input_image, discard_pixels);

% create a binary image
binary_image = edge(input_image,'canny');    
imshow(binary_image);

2 个答案:

答案 0 :(得分:1)

答案很简单,您的函数var contacts = [ { "firstName": "Akira", "lastName": "Laine", "number": "0543236543", "likes": ["Pizza", "Coding", "Brownie Points"] }, { "firstName": "Harry", "lastName": "Potter", "number": "0994372684", "likes": ["Hogwarts", "Magic", "Hagrid"] }, { "firstName": "Sherlock", "lastName": "Holmes", "number": "0487345643", "likes": ["Intriguing Cases", "Violin"] }, { "firstName": "Kristian", "lastName": "Vos", "number": "unknown", "likes": ["Javascript", "Gaming", "Foxes"] } ]; function lookUpProfile(firstName, prop) { for (var i=0; contacts.length>i; i++) { if (contacts[i]['firstName']==firstName) { if (contacts[i].hasOwnProperty(prop) === true) { return contacts[i][prop]; } else { return "No such property"; } } return "No such contact"; } } console.log(lookUpProfile("Akira", "lastName"));会将图像值更改为靠近图像边框的0。

因此它在图像值和0之间创建了步骤 这正是Canny Edge Detector所寻找的。

如果在应用此功能后显示图像,则可以轻松看到它。

不要使用该功能。

答案 1 :(得分:1)

应用discard_image_area功能后应用edge。否则,丢弃的区域显然是边界。即这样做:

image_name = 'canny_test.png';
discard_pixels = 10;
input_image =  rgb2gray(imread(image_name));  % there is no such this as gray_imread

% create a binary image
binary_image = edge(input_image,'canny');    

% discard border area
binary_image = discard_image_area(binary_image , discard_pixels);

imshow(binary_image);

<强>输出:

output