What do the pixelIdxlist mean?

Hi, i used the bwconncomp in the matlab for an image. The resultant is a struct with 4 fields and the pixelIdxList field in that has size of 1x801 with some numbers in each column. What are those numbers actually? What do they signify? For e.g. what 98475, 98586 in CC{5,2} means?

Réponses (2)

Hyeokjin Jho
Hyeokjin Jho le 18 Fév 2020

0 votes

Let's say your image input for bwconncomp is BW. i.e.
CC = bwconncomp(BW);
Then CC.pixelIdxList{i} is linear indices of i-th identified component in BW.
You can index that component in the image BW using this value. For example
BW(CC.pixelIdxList{10}) = false;
will make 10th component in BW become false.

9 commentaires

Sk
Sk le 18 Fév 2020
Thank you Jho. But that i-th column sometimes has both single value and multiple values in it, for eg. the values like 98457,99482,102564 and so on. What are they?
Hyeokjin Jho
Hyeokjin Jho le 18 Fév 2020
Connected component can be multiple pixels (in fact, most of the time). Those indices are positions of all of those connected pixels.
Sk
Sk le 19 Fév 2020
Modifié(e) : Sk le 19 Fév 2020
CC = bwconncomp(h,26);
v=CC.NumObjects;
for x=1:1:v
for i = 1:size(x)
length(x,i) = length(x(i)); % Number of elements in each cell
end
if length(x)>=1
h(CC.PixelIdxList(x)) = false; % if more than 1 connected components exists then make that as zero pixels
end
end
Okay Jho, got clarified. And I need to access the indices values for all (801) columns (values inside every column of array cell i.e. 85338,etc). I tried by this code but im not getting it. Pls help me.
Hyeokjin Jho
Hyeokjin Jho le 21 Fév 2020
Based on your code, Your purpose seems like you want to make every connected component larger than 1px become false. Is it true? or you want to collect all of the indices in each connected components into one array? What do you mean by "access the indices"?
I cannot catch your purpose clearly. Can you elaborate more?
Sk
Sk le 24 Fév 2020
Yeah Jho, i want to make every connected components larger than a certain px become false.
Walter Roberson
Walter Roberson le 24 Fév 2020
Using length as a variable name is very likely to cause problems.
Sk
Sk le 24 Fév 2020
I have not used length as a variable name. I have used its functionality with the indexes within brackets.
Sk, yes you did when you did this:
length(x,i) = length(x(i));
You're using the length() function to take the length of x(i) (which is probably just 1 if x(i) is a scalar), and then putting that length value (1) into a 2-D matrix called "length", because, of course, you can't assign a function to a value. So what that did was to essentially overwrite the length() function with a new variable called length. So the next time the loop iterates, it won't call the length function but will instead try to get the element of the length matrix at the x(i)'th location.
Sk
Sk le 24 Fév 2020
Okay Image Analyst i got. Since that is the index of the cell i gave like that. Then how else that can be given? For the above posted image, for eg. how can i get the values in cell (3,1) ?

Connectez-vous pour commenter.

Image Analyst
Image Analyst le 21 Fév 2020

0 votes

Sk, are you trying to filter based on blob size? If so, check out bwareaopen() or bwareafilt().

3 commentaires

Sk
Sk le 24 Fév 2020
@Image Analyst, im trying to filter out the unwanted areas i.e. the areas that are not continously connected and make them as false and only the areas that are connected contiously to be true. For that can i use bwareaopen() or bwareafilt()? If so pls give me some idea on that.
Image Analyst
Image Analyst le 24 Fév 2020
All areas are continuously connected to something, except for the sole case of isolated single pixels.
Post your image and indicate (like with arrows or outlines or something) which blobs are the ones you want to keep (the "connected contiously" ones), and which you want to exclude (the "not continously connected" ones).
Sk
Sk le 24 Fév 2020
In this image, im trying to get the letters alone. As there are many other unwanted pixels around the letters in the image, i need to set the largely connected components as false and others as true, so that the letters alone are seen and the noisy pixels are made black.

Connectez-vous pour commenter.

Question posée :

Sk
le 17 Fév 2020

Commenté :

Sk
le 24 Fév 2020

Community Treasure Hunt

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

Start Hunting!

Translated by