Info
此问题已关闭。 请重新打开它进行编辑或回答。
How we can check for more than one edge passing through a pixel
1 次查看(过去 30 天)
显示 更早的评论
Some pixel have more than one edge how can determine the number of edges passing through one pixel.
0 个评论
回答(2 个)
Image Analyst
2014-4-1
If the edges are binary, like the pixel is 1 if an edge is at that pixel and 0 if there is no edge there, then you can just identify pixels that have more than 2 neighbors.
kernel = [1,1,1;1,0,1;1,1,1]; % Map of where the 8 neighbors lie.
numNeighbors = conv2(binaryEdgeImage, kernel, 'same'); % Count neighbors
moreThan1 = numNeighbors >= 3; % Binary image: 1 if 3 or more neighbors at each pixel.
imshow(moreThan1); % Display it.
0 个评论
Ashish Uthama
2014-4-1
When looking for 3x3 (or 2x2) patterns, BWLOOKUP is usually faster and more flexible:
function bw = multiedge(bwedge)
lut = makelut(@getlookup, 3);
bw = bwlookup(bwedge,lut);
function isMultiEdge = getlookup(x)
% See help for makelut. You can customize what a 'multi edge'
% pixel ought to look like.
x(2,2) = 0;
isMultiEdge = sum(x(:))>=3;
end
end
Note - You need to define what you mean by multiedge. For example, IA's and the above code snippet will give:
edge =
1 1 0
0 1 0
0 0 1
>> multiedge(a)
ans =
0 0 0
1 1 1
0 0 0
3 个评论
Ashish Uthama
2014-4-1
In either case, a non edge pixel cannot be a multiedge pixel, correct? ((2,1) in ans above).
So Adel should either (preferably) fold his/her definition of multiedge into the computation, or clean up the results by masking in with the original edge image.
Image Analyst
2014-4-1
True. In my code I should have made sure that the center pixel was 1 instead of "don't care". I guess that's the kind of mistakes that show up sometimes when I just post code off the top of my head and don't test them.
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!