Binary Element Distance Function (similar to graycomatrix)
조회 수: 1 (최근 30일)
이전 댓글 표시
I would like a function that takes a binary image, and outputs the minimum distance between connected elements of different sizes.
Example:
BW =
1 1 0 1 0
0 0 0 1 0
0 0 0 0 0
1 1 0 0 0
1 0 0 0 1
MinimumDistanceMatrix =
0 2 2 0 0 0
2 1 1 0 0 0
2 1 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
This output is similar to the graycomatrix output matrix, suchthat value (1,1) represents the minimum distace between any 2 elements of size 1 and 1. And (2,1) represents the minimum distace between any 2 elements of size 2 and 1.
Note: The result will always be a symmetric matrix because the minimum distance from 2 elements of size i and j will be identical to the minimum distance from 2 elements of size j and i.
I have started going down the path of using bwlabel on the initial binary image to get a matrix of each unique elements.
LabeledBW =
1 1 0 3 0
0 0 0 3 0
0 0 0 0 0
2 2 0 0 0
2 0 0 0 4
Then selecting each element and changing each value of the element to be the size of the element.
BWElementSize =
2 2 0 2 0
0 0 0 2 0
0 0 0 0 0
3 3 0 0 0
3 0 0 0 1
But form here the only way I have thought of to get to the result I want is to use the graycomatrix function in a rediculous set of loops which will be sure to be very slow and I want to avoid coding.
So if anyone has any sugestions I would love to hear them. I feel like I am headed down the wrong path with the loops and there must be a better way to do this.
Thanks, Barrett
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Convert Image Type에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!