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!