Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How we can check for more than one edge passing through a pixel

1 回表示 (過去 30 日間)
Adel
Adel 2014 年 4 月 1 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Some pixel have more than one edge how can determine the number of edges passing through one pixel.

回答 (2 件)

Image Analyst
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.

Ashish Uthama
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
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
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!

Translated by