How to create a linkage between different blob?
2 次查看(过去 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!