Create line of pixels on an image

3 ビュー (過去 30 日間)
David Harra
David Harra 2022 年 9 月 14 日
コメント済み: Image Analyst 2022 年 9 月 15 日
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

採用された回答

Image Analyst
Image Analyst 2022 年 9 月 14 日
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 件のコメント
David Harra
David Harra 2022 年 9 月 14 日
So my end goal is the Two Point Correlation function but this is the main part I am trying to acgieve. This function is a probability distribution of the distribution of grain sizes.
For example
you can randomly choose 1 million pairs of pixels, each pair has a distance of a given value ‘r’ , into this image, and count the number of pairs that are in the same grains. So we would need to generate a random number of points using the randi function - I just can't seem to get it to work.
Apologies if my explanation is vague, its the best I can explain it
Image Analyst
Image Analyst 2022 年 9 月 15 日
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]);

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with Image Processing Toolbox についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by