# Find the edge of an image

2 views (last 30 days)
Sharen H on 10 Jul 2013
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?

David Sanchez on 10 Jul 2013
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 CommentShowHide None
Sharen H on 10 Jul 2013
When i do this the values present in nI is also binary and not gray ...Please help

David Sanchez on 10 Jul 2013
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.
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