Labelling edges in an image
조회 수: 5 (최근 30일)
이전 댓글 표시
I am trying to do what should be a really basic image processing task, but don't seem to be able to find a particular neat solution so hopefully someone can suggest one.
I simply wish to find the edges between three coloured segments of the image below as single-pixel thick lines with 3 distinct values representing the 3 different boundary possibilities. I don't care what the 3 distinct values are so long as they are distinct.

This is the solution I want (ignore the colourmap, I was just trying to find colours that made it easy to distinguish) - here the 3 values happen to be 3, 4, 5.

My method for achieving it was:
f = @(x) ( x(2) ~= x(1) ) * ( x(2) + x(1) );
edgeRes = nlfilter( wedge, [1 2], f );
i.e. basically just looking at a 1*2 window and adding together the two values in the window if they differ.
I don't like this solution much though as nlfilter throws up a progress bar (plus it feels like there should be a much simpler method).
The input data and the edge result I have should be in the attached .mat file if anyone has any better idea for achieving this seemingly trivial task!
댓글 수: 0
채택된 답변
Ahmet Cecen
2014년 11월 6일
For this particular image and any image with a similar enough trivial nature, there is a very short solution: A is your image with 3 regions which are 1 2 and 4, use circshift to shift A left by 1 pixel, then add the shifted image with the original image. Now anywhere with a 3 is a 1 2 boundary, 5 is a 1 4 boundary 6 is a 2 4 boundary.
추가 답변 (0개)
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!