Create line of pixels on an image

21 views (last 30 days)
I am trying to achieve the Two Point Correlation function for a distribution of grain sizes.
As a practice example, I have generated mimic grain diagram using voronoi.
x = rand([1 100]);
y = rand([1 100]);
voronoi(x,y)
What I am now trying to achieve is to pick a line across the bulk of the image and have this line made of say around 1000 pixels. Each pair of pixels will be separated by some distance 'r'. Then I would then like to know how many pixels belong to each grain. (Different grains will have different pixel values.)
I have researched using the line command amongst other things but I can't get anything close to what I need. Any help would be appreciated.
Thanks

Accepted Answer

Image Analyst
Image Analyst on 14 Sep 2022
Does the orientation of the line matter? I think not. So why don't you just scan down the image line by line. To find out how many pixels are in each grain intensity you can take the histogram. Of course if you scan down the entire image that will just give you the histogram of the entire image. Not really sure what you're after. Do you just want to know the area fraction of a certain grain type? Not sure what you mean by having pixels separated "r" from the line. Wouldn't that just mean you have two lines? Is that because you're trying to determine the likelihood of one grain type being adjacent to another grain type?
  2 Comments
Image Analyst
Image Analyst on 15 Sep 2022
That sounds like what they did in the old days, like 50 years ago before they had computers and had to do stuff manually using sterological techniques.
These days we have computers and we can simply operate on every single pixel in the image. We don't need to take random samples anymore.
Since you seem to know what grain is where (you would have to in order to do what you were planning), you must already have labeled your image. So in that case, simply take the histogram of the labeled image to give the relative frequency of grain pixels. You can also do particle sizing on it if you want to get a distribution of areas of individual grains.
props = regionprops(labeledImage, 'Area');
allAreas = sort([props.Area]);

Sign in to comment.

More Answers (0)

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by