sum pixel value in an image.
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ahmad Alenezi
el 20 de Sept. de 2019
Comentada: Subhadeep Koley
el 4 de Nov. de 2019
Hi all,
I have a series of images in one dicom file (n =16 images). How can i find frames that contain maximum and minimum sum of pixel values (i.e. signals) and how to find their corresponding values (i.e. the sum of pixel values for the maximum frame and minimum frame) ?
the file is called MUGA.dcm
0 comentarios
Respuesta aceptada
Divya Yerraguntla
el 23 de Sept. de 2019
Hi Ahmad,
Try using the following code to find the sum of pixels of images in DICOM file.
n=[];
% Find sum of images by providing your DICOM file name
for i=1:10
[X, map] = dicomread('DICOM filename','frames',i);
n = [n,sum(X(:))];
end
% Find maximum and minimum summation and indices.
[min, minidx] = min(n);
[max, maxidx] = max(n);
Hope it helps!
1 comentario
Más respuestas (3)
Divya Yerraguntla
el 27 de Sept. de 2019
Hi Ahmad,
- Yes, the dicomread function returns the pixel values of the file and stores it in variable X in the above mentioned code.
- The variable maxidx in the above code gives the frame number which has the maximum pixel sum value and variable max gives the pixel sum of that frame.
- 'frames' indicates the frames to read, specified as an integer scalar, a vector of integers, or 'all'. When value of 'frames' is numeric, dicomread reads only the specified frame numbers from the image. By default, dicomread reads all frames of the DICOM image.
Hope it helps!
3 comentarios
Divya Yerraguntla
el 4 de Oct. de 2019
Hi Ahmad,
The code and file you have provided are giving the following results.
![Dicom-Workspace.PNG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/241107/Dicom-Workspace.png)
Are these the expected ones?
0 comentarios
Ahmad Alenezi
el 4 de Oct. de 2019
7 comentarios
Subhadeep Koley
el 4 de Nov. de 2019
I think the DICOM file you are using has less than 16 channels.
However, please use the code below. It is more generalized and will work for DICOM files of any channel length.
clear;close all;clc;
X = rescale(squeeze(dicomread('MUGA1.dcm'))); % Read your DICOM
temp = rescale(X(:,:,1)); % Select one frame from the mask generation
mask = roipoly(temp); % Specify polygon ROI with the interactive polygon selection tool
X_masked = zeros(size(X)); n = [];
for i=1:size(X,3)
for j=1:128
for k=1:128
if(mask(j,k) == 1)
X_masked(j,k,i) = X(j,k,i);
n = [n,sum(X_masked(:))];
end
end
end
end
% Find maximum and minimum summation and indices.
[minVal, minIdx] = min(n);
[maxVal, maxIdx] = max(n);
Hope this helps!
Ver también
Categorías
Más información sobre DICOM Format en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!