How to find minimum Pixel value?

조회 수: 7 (최근 30일)
Sin j
Sin j 2020년 3월 9일
댓글: Sin j 2020년 3월 9일
Hi there,
I have 64*64 pixel Image and value are measured in 40s withe Image Rate (47 1/s). Image file is 64*64*1913 double, I want to find location for minimum Pixel Value (row and colmns) in region (32:64, 32:64) in all of the time. I used these two codes but it didn't work.
[row, column] = find(min(squeeze(nanmean(squeeze(nanmean((imgfilt(32:64,32:64,:)))))) == 1))
row =
[]
column =
[]
% % % % % % % % % % % % % % % % % % %
>> M = (min(nanmean(nanmean( imgfilt(32:64,32:64,: ),2),1)));
[min_val,idx] = min(M(:))
[row,col] = ind2sub(M,idx)
min_val =
-3.6858e+14
idx =
1
row =
1
col =
1

채택된 답변

Image Analyst
Image Analyst 2020년 3월 9일
You should be able to do
minValue = min(thisImage(:))
[row, column] = find(thisImage == minValue);
for each time point (slice of your 3-D image volume). Here is a full demo:
imgfilt = randi(65535, 64, 64, 1913); % Create sample data. You, of course, would use your own.
imgfilt(44:66) = nan;
[rows, columns, numberOfTimePoints] = size(imgfilt)
for slice = 1 : numberOfTimePoints
% Get the image for this time point.
thisImage = imgfilt(32:end, 32:end, slice);
minValue = min(thisImage(:));
[row, column] = find(thisImage == minValue);
% To get original indices, need to add 31 to the row and column
row = row + 31;
column = column + 31;
% Store the rows and columns where this time point image equals the min.
% We are using a cell array because each image may have a different number
% of locations where the min occurs.
ca{slice, 1} = row;
ca{slice, 2} = column;
% For fun, print them out.
for k = 1 : length(row)
r = row(k);
c = column(k);
fprintf('For time point %d, the min value of %f occurs at row %d, column %d.\n', ...
slice, imgfilt(r, c, slice), r, c);
end
end
  댓글 수: 1
Sin j
Sin j 2020년 3월 9일
Thank you, this is right answer.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by