Filter löschen
Filter löschen

How to create a linkage between different blob?

3 Ansichten (letzte 30 Tage)
Tan Wen Kun
Tan Wen Kun am 1 Dez. 2015
Bearbeitet: Tan Wen Kun am 3 Dez. 2015
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 Kommentare
Tan Wen Kun
Tan Wen Kun am 2 Dez. 2015
Bearbeitet: Tan Wen Kun am 2 Dez. 2015
now I get the relationship table so I decide to merge them together based on the original image color pixel.
example blob.jpg:
blob 1(rgb=122,122,122) and blob 2(rgb=121,121,121) the color is nearly same(threshold maybe set to rgb+-10) so I reassign label blob 2 to label blob 1.
blob 3 maybe pixel value(10,12,13) on original image is huge different with blob 1 so I decide not merge to blob 1.
Problem I faced now is how to compare matrix of color blob (x,y)position with matrix impixel of original image so I can decide whether want to merge different blob together or not?
Walter Roberson
Walter Roberson am 2 Dez. 2015
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"

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 2 Dez. 2015
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 Kommentare
Walter Roberson
Walter Roberson am 3 Dez. 2015
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
Tan Wen Kun
Tan Wen Kun am 3 Dez. 2015
Bearbeitet: Tan Wen Kun am 3 Dez. 2015
Because I got the blob table so I just need to compare like blob 1 is connected to blob 2 and 3 so I only compare the original rgb of blob 1 and 2 and then blob 3 and blob1.
This 2 line is label a position only~I need compare the median whole blob 1 in original image and median whole blob2 in original image.
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
can I chg this to a loop so i can loop all the blob
for(x=1,x++,x<=maxblob)
first_lab=blob x
second_lab=blob x+1
first_color = cmap(first_lab,:); %rgb corresponding
second_color = cmap(second_lab,:); %rgb corresponding
end
if YourFunctionToTellIfColorsAreClose(first_color, second_color)
//compare median rgb of blob x&&blobx+1 =threshold+-5
//if first_color<= second_color threshold+-5 || first_color>=
second_color threshold+-5
//chg label blob x+1 =blob x
end
I usually is using C++ so matlab code I quite unfamiliar.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by