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

 採用された回答

Divya Yerraguntla
Divya Yerraguntla 2019 年 9 月 23 日

0 投票

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 件のコメント

Ahmad Alenezi
Ahmad Alenezi 2019 年 9 月 25 日
編集済み: Ahmad Alenezi 2019 年 9 月 25 日
Hi Divya
Does this find the pixel values (signals) of pixel count ?
And how to find that which frame got the highest values ?
And what does 'frames' indicate for ?
Best, Ahmad

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

その他の回答 (3 件)

Divya Yerraguntla
Divya Yerraguntla 2019 年 9 月 27 日

0 投票

Hi Ahmad,
  1. Yes, the dicomread function returns the pixel values of the file and stores it in variable X in the above mentioned code.
  2. 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.
  3. '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.
Have a look at dicomread for more information on the function.
Hope it helps!

3 件のコメント

Ahmad Alenezi
Ahmad Alenezi 2019 年 9 月 27 日
Thank you for you reply.
the code is giving me the following results.
i = 16
max = 5027636
maxidX = 1
min = 5027636
minidX = 1
These results are not expected !
do you know what could be the problem ?
i used the code as below:
n=[];
% Find sum of images by providing your DICOM file name
for i=1:16
[X, map] = dicomread('MUGA.dcm','frames',i);
n = [n,sum(X(:))];
end
% Find maximum and minimum summation and indices.
[min, minidx] = min(n);
[max, maxidx] = max(n);
Divya Yerraguntla
Divya Yerraguntla 2019 年 9 月 27 日
Could you provide MUCA.dcm file?
Ahmad Alenezi
Ahmad Alenezi 2019 年 9 月 30 日
This is the file.
Thanks.

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

Divya Yerraguntla
Divya Yerraguntla 2019 年 10 月 4 日

0 投票

Hi Ahmad,
The code and file you have provided are giving the following results.
Dicom-Workspace.PNG
Are these the expected ones?
Ahmad Alenezi
Ahmad Alenezi 2019 年 10 月 4 日

0 投票

Hi Divya,
Yes, these results are the expected. Thanks indeed
One last question:
I know how to apply region of interest over a small part of the image (see image). This results in 128x128x16 uint 16 array (I call it ROI). How can I put ROI instead of dicomread('MUGA.dcm').?? meaning that i want my input to be ROI instead of MUGA.dcm
roi muga.png
Best,
Ahmad

7 件のコメント

Image Analyst
Image Analyst 2019 年 10 月 4 日
Do you want to just erase (make black) everything outside the mask and then process the image?
maskedImage ==grayImage
maskedImage(mask) = 0;
or do you want to just get a list of all pixels inside the mask in a 1-D list and do something with them?
pixelsInMask = grayImage(mask);
Ahmad Alenezi
Ahmad Alenezi 2019 年 10 月 4 日
Hi
the first case is exactly what i want.
How can i combine the cose you provided (first) with the below code ?
n=[];
% Find sum of images by providing your DICOM file name
for i=1:16
[X, map] = dicomread('MUGA.dcm','frames',i);
n = [n,sum(X(:))];
end
% Find maximum and minimum summation and indices.
[min, minidx] = min(n);
[max, maxidx] = max(n);
Subhadeep Koley
Subhadeep Koley 2019 年 11 月 3 日
You can use the roipoly() function to launch an interactive tool which can generate a binary mask for your ROI. When the polygon tool is active, using the mouse, you specify the region by selecting vertices of the polygon. You can move or resize the polygon using the mouse. When you are finished positioning and sizing the polygon, create the mask by double-clicking, or by right-clicking inside the region and selecting Create mask from the context menu.
Use the code below.
clear; close all; clc;
X = 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:16
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.
[min, minidx] = min(n);
[max, maxidx] = max(n);
Hope this helps Ahmad!
Ahmad Alenezi
Ahmad Alenezi 2019 年 11 月 4 日
Hi Subhadeeb
thank you very much for answering my question.
i applied the code, but i am getting this error:
Index in position 3 exceeds array bounds (must not exceed 1).
Error in United (line 10)
X_masked(j,k,i) = X(j,k,i);
Do you know what is the problem ?
Subhadeep Koley
Subhadeep Koley 2019 年 11 月 4 日
Ahmad, the code is running in my end without any error. I am using the the attached DICOM file.
Ahmad Alenezi
Ahmad Alenezi 2019 年 11 月 4 日
Thank you !
Subhadeep Koley
Subhadeep Koley 2019 年 11 月 4 日
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!

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

カテゴリ

ヘルプ センター および File ExchangeDICOM Format についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by