【发布时间】:2013-01-25 05:02:06
【问题描述】:
你好,作为我家庭作业的一部分。我需要计算并显示边缘幅度图像和 图像balls1.tif的边缘方向图像,使用Sobel边缘检测。
不要使用 matlab 的边缘函数。您可以使用 conv2。 显示强边缘像素(高于阈值)的二值边缘图像(1 个边缘像素,0 个无边缘)。 确定消除球阴影的阈值。
这是我的 main.m
addpath(fullfile(pwd,'TOOLBOX'));
addpath(fullfile(pwd,'images'));
%Sobel Edge Detection
Image = readImage('balls1.tif');
showImage(Image);
message = sprintf('Sobel Edge Detection');
sobelEdgeDetection(Image);
uiwait(msgbox(message,'Done', 'help'));
close all
这是我的 SobeEdgeDetection.m
function [ output_args ] = SobelEdgeDetection( Image )
maskX = [-1 0 1 ; -2 0 2; -1 0 1];
maskY = [-1 -2 -1 ; 0 0 0 ; 1 2 1] ;
resX = conv2(Image, maskX);
resY = conv2(Image, maskY);
magnitude = sqrt(resX.^2 + resY.^2);
direction = atan(resY/resX);
thresh = magnitude < 101;
magnitude(thresh) = 0;
showImage(magnitude);
end
我的问题是:
1.我用的方向是什么?我怎样才能显示它?
2.有没有更好的方法来获得消除球阴影的阈值。我用反复试验....
就显示幅度而言,这些是我的结果:
【问题讨论】:
-
direction - 是图像上的梯度方向,它与物体边缘正交。您的图像不会让您消除阴影:在这种情况下,您会失去一些上边框。
标签: image matlab image-processing