getting statistics from within a mask within an image

5 ビュー (過去 30 日間)
JM
JM 2024 年 8 月 16 日
移動済み: Walter Roberson 2024 年 8 月 19 日
We have an image that represents data that only makes sense when it is analyzed in numerical format.
Specifically, the data needs to be analyzed as a function of radius as shown below
Im interested specifically in hte max and min values within each of the defined areas with respect to the center point.
Ive been looking at a few examples online and it seems this should work when you pull the data from a mask.
However, the issue is that I seem to be getting values that are not realistic.
this is what I am doing
clear
img = double(imread('img121.jpg'));; %no filtration
img = -(0.0316*img) +8.3; % we did this as we cant calibeate the film, we scan the same film over and over and it changes by 80pixels
img = imrotate(img, 90);
img = imgaussfilt(img ,1.5);
figure, imagesc(img )
axis image
height2 = 3.6;
caxis([0 height2])
colorbar
title(' ')
impixelinfo
%# make sure the image doesn't disappear if we plot something else
hold on
%https://www.mathworks.com/matlabcentral/answers/1931825-how-to-get-pixel-value-inside-a-circle
%below looks like what we want
%https://www.mathworks.com/matlabcentral/answers/1931825-how-to-get-pixel-value-inside-a-circle
%# define points (in matrix coordinates)
%3"
cpx = 2050;
cpy = 2020;
inchlist = [12,10.5,9,7.5,6,4.5];
%draw lines on heel axis
for n=1:size(inchlist,2)
inch= inchlist(n)/4;
hcirc = drawcircle('Center',[2050,2020],'Radius',inch*590,'StripeColor','red');
mask1 = hcirc.createMask;
maxval = (max(img(mask1)));
minval = (min(img(mask1)));
uniformity = maxval/minval
% p1 = [cpy-100,cpx+inch*590];
end
uniformity = 6.8965
uniformity = 5.3893
uniformity = 5.3893
uniformity = 5.3893
uniformity = 3.7992
uniformity = 1.9168
Even after getting this max and min value, I will need to remove 10 to get rid of noise. Extra credit if you can point me to a soluton for that too.
thank you
  3 件のコメント
JM
JM 2024 年 8 月 19 日
移動済み: Walter Roberson 2024 年 8 月 19 日
Anyone have any thoughts?
JM
JM 2024 年 8 月 19 日
移動済み: Walter Roberson 2024 年 8 月 19 日
all set

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

採用された回答

Walter Roberson
Walter Roberson 2024 年 8 月 16 日
移動済み: Walter Roberson 2024 年 8 月 16 日
To find out where the maximum of the masked image is:
IdxImg = reshape(1:numel(img), size(img));
masked_image_idx = IdxImg(mask1);
[max_value, max_idx] = max(img(mask1));
index_of_max = masked_image_idx(max_idx);
[MaxRow, MaxColumn, MaxPage] = ind2sub(size(img), index_of_max);
This works by creating an indexing image the same size as the original image, but containing 1, 2, 3, ... all the way up to the maximum array element number. Then you extract the portion of the indexing image under the mask, to get a vector of the element numbers covered by the mask. Then take the max() of the masked image, getting out the (linear) index of the maximum element. Use the linear index of the maximum element to index the vector of indexing array elements selected by the max, getting out the linear index of the array element in the original image. Then convert the linear index back to subscripts if necessary.
  1 件のコメント
JM
JM 2024 年 8 月 19 日
編集済み: JM 2024 年 8 月 19 日
Walter,
I appreciate the help with this function to get the max and min values. I admit I dont totaly understand the masking.
Using the coordinates returned from the code you provided, Im still not able to see the pixel values being retuned as the max and min that make sense with the orignal image. There is something funny going on.
I have attached the orignal image that is being run with the script.
from scanning through the areas defined by the mask, I would expect each region to produce a max and min that produce uniformity (max/min) that is around 1 to 2. However, we are getting values of like 8 which is not possible. Yes, there are noise points in there but nothing to produce large values like this.
thank you again.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by