Find distance between foregrounds of two binary images

조회 수: 4 (최근 30일)
Simon Schiele
Simon Schiele 2020년 9월 16일
댓글: Simon Schiele 2020년 9월 21일
I have an image that looks like this:
I found the colored lines using hough transform.
I would now like to measure the width of the corresponding thick lines in the image.
I can draw a second image based on the Hough lines (the sizes of the images are equal, looks different here because they are screenshots):
So my basic idea is using something similar to bwdist to calculate the distance between all points in image one to those in image 2.
Any ideas?

답변 (1개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2020년 9월 16일
Steps:
1.As you already know the indices of all three lines from the 2nd image. If not following is the way
[r2 c2]=find(image2==1);
2. Next force the all pixel with zero of r2 and c2 in 1st image. the find the indices the all white pixel in first image
[r1 c1]=find(image1==1);
3. Calculate the distances between all sets of [r1,c1] and [r2,c2]. Tou can proceed the first index pair of (r2,c2) with all indices pair in image 1, which are [r1,c1]. Next another index pair of (r2,c2) with all indices pair in image1..so on
At last you will get the distances between all three lines and all other white pixels in the image.
Hope it helps!
Kalyan
  댓글 수: 1
Simon Schiele
Simon Schiele 2020년 9월 21일
Thanks for your comment! This seemed a bit expensive to me, so I tried a different approach. I treat each line separateley. I first invert the line image and calculate the distance from this inverted image to the background using bwdist. This gives the distance of each line to any point in the image. Then I use my original binary image as mask to remove all distances from line to background. The histogram can then be used to find the width of the lines.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by