How to create a linkage between different blob?
조회 수: 1 (최근 30일)
이전 댓글 표시
For example I using watershed and get different color piece.
I want to create a matrix to show the linkage.
1 1 1 1 1 1 1 1 1 1 1
1 2 2 1 3 3 1 4 4 0 1
1 2 1 3 3 1 0 4 4 0 1
1 1 1 1 1 1 1 1 1 1 1
so when loop vertical and horizontal I wish to get the result like matrix.jpg
I want check before 1 and after 1,
if check got 2,3 so return 1 to matrix(3,2)=1 matrix(2,3)=1
if check got 3,4 so return 1 to matrix(3,4)=1 matrix(4,3)=1
if 0 then ignore.
How to do this?
댓글 수: 6
Walter Roberson
2015년 12월 2일
You need to define when two colors are "nearly the same" or not. It is not an easy question, especially when you are working with the darker colors. For example, is [10,0,0] "nearly the same" as [0,0,0] because the values are within 10, or is [10,0,0] definitely "red" whereas [0,0,0] is "black" ?
You should look for some of what Image Analyst has posted about "Delta E"
채택된 답변
Walter Roberson
2015년 12월 2일
Use glcm on the blob numbers. This will give you counts instead of just yes/no, but you can get the yes/no by just testing whether the count > 0.
댓글 수: 5
Walter Roberson
2015년 12월 3일
If you have a function that can return whether two rgb colors are "close" or not, then you pass in to that table the pseudocolor map indexed at the blob number. For example,
[ind_image, cmap] = rgb2ind(TheColorImage);
labeled_image = ind_image + 1; %because first color of ind is 0
first_lab = labeled_image(7,38); %label of one place in the image
second_lab = labeled_image(11,20); %label of a different place in the image
first_color = cmap(first_lab,:); %rgb corresponding
second_color = cmap(second_lab,:); %rgb corresponding
if YourFunctionToTellIfColorsAreClose(first_color, second_color)
....
end
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!