Find the edge of an image
2 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(2 个)
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
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
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!