How to find minimum Pixel value?
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Sin j
am 9 Mär. 2020
Kommentiert: Sin j
am 9 Mär. 2020
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
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 9 Mär. 2020
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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!