Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

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

1 visualización (últimos 30 días)
Adel
Adel el 1 de Abr. de 2014
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
Some pixel have more than one edge how can determine the number of edges passing through one pixel.

Respuestas (2)

Image Analyst
Image Analyst el 1 de Abr. de 2014
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 el 1 de Abr. de 2014
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 comentarios
Ashish Uthama
Ashish Uthama el 1 de Abr. de 2014
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 el 1 de Abr. de 2014
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.

La pregunta está cerrada.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by