sum pixel value in an image.
이전 댓글 표시
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
채택된 답변
추가 답변 (3개)
Divya Yerraguntla
2019년 9월 27일
0 개 추천
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
Ahmad Alenezi
2019년 9월 27일
Divya Yerraguntla
2019년 9월 27일
Could you provide MUCA.dcm file?
Ahmad Alenezi
2019년 9월 30일
Divya Yerraguntla
2019년 10월 4일
0 개 추천
Hi Ahmad,
The code and file you have provided are giving the following results.

Are these the expected ones?
Ahmad Alenezi
2019년 10월 4일
0 개 추천
댓글 수: 7
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
2019년 10월 4일
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
2019년 11월 4일
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
2019년 11월 4일
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 Exchange에서 Convert Image Type에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
