Find the edge of an image

2 次查看(过去 30 天)
Sharen H
Sharen H 2013-7-10
I wanted to find the edge in an palm image .when i use edge command i am able to get the edge but the output is in binary form. Is there any command to show the same edge representation in my original gray image?

回答(2 个)

David Sanchez
David Sanchez 2013-7-10
There is shorter way to do this, but the idea is this:
[rows cols] = size(I);
nI = zeros(rows,cols);
for row = 1:rows
for col = 1:cols
nI(row,col) = I(row,col)*double(BW(row,col));
end
end
imagescc(nI);
where I is your palm image and BW the image returned by edge and nI the image containing the edges with pixel values (gray scale values in your case) instead of ones
  1 个评论
Sharen H
Sharen H 2013-7-10
When i do this the values present in nI is also binary and not gray ...Please help

请先登录,再进行评论。


David Sanchez
David Sanchez 2013-7-10
Are you sure you are assigning matrices correctly? Try this out. In this case, I is an image in matlab database. nI can not be binary since neither I nor double(BW) are.
I = imread('circuit.tif');
BW = edge(I,'prewitt');
[rows cols] = size(I);
nI = zeros(rows,cols);
for row = 1:rows
for col = 1:cols
nI(row,col) = I(row,col)*double(BW(row,col));
end
end
imagesc(nI);
>> whos
Name Size Bytes Class Attributes
BW 280x272 76160 logical
I 280x272 76160 uint8
col 1x1 8 double
cols 1x1 8 double
nI 280x272 609280 double
row 1x1 8 double
rows 1x1 8 double

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by