MATLAB Answers

0

How to connect each pair of pixels Image A taken from image B (Image A and Image B are given as under)

Asked by Mohammad Bhat on 14 Jul 2018 at 7:15
Latest activity Edited by Mohammad Bhat on 16 Jul 2018 at 6:31

Hi,

I have extracted some pixels (based on some criteria ) from image A and got Image B

as shown below.

Now, I need to connect each pair pixel of Image B, if the corresponding points/pixels are connected in A?? How to do that.???

  0 Comments

Sign in to comment.

1 Answer

Answer by Image Analyst
on 14 Jul 2018 at 14:54
Edited by Image Analyst
on 14 Jul 2018 at 14:55

Very easy. Just call bwlabel on A

[labeledImage, numRegions] = bwlabel(A);

where A is a binary image.

Then use find() and pdist2() (stats toolbox) on B to get distances and select the smallest non-zero distance - trivial, but let me know if you can't do it.

Then, for your two pixels locations in B you want to check on, simply check if the labels are the same or different.

if labeledImage(row1, col1) == labeledImage(row2, col2)
    % Those two locations in B are on the same curve in A
else
    % Those two locations in B are on different curves in A
end

  3 Comments

Read this http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer

and then upload your original image A and image B. Also provide what you'd like your final image to look like - mock something up in Photoshop if you have to.

Sir,

Here the Images are shown in the pipeline, respectively.

Third Image (from left to right) is desired image

(pixels shown in desired image are shown apart for understanding, )

Sign in to comment.