how to fix the rescale slope with own pixel

조회 수: 3 (최근 30일)
mohd akmal masud
mohd akmal masud 2018년 11월 1일
댓글: Rik 2018년 11월 1일
Anybody please help me
This is code for get the x, y, z(slice number), and pixel value. Then the second one below is my code to get the rescale slope for each slice.
My question is how to set up the pixel value is automatically multiply with theor own rescale slope?
Because the rescale slope and the pixel value have extract seperately.
P = zeros(256, 256, 47);
for K = 20 : 31
petname = sprintf('PETWB001_PT%03d.dcm', K);
P(:,:,K) = dicomread(petname);
end
numOfPixels = numel(P(:));
max(P(:));
sum(P(:));
mask = (P >= 20000 & P <= 32767);
numPixelsInRange = sum(mask(:));
sum(P(P>=20000 & P<=32767));
[r,c,slice] = findND(P >= 20000 & P <= 32767)
val=P(P(:)>=20000 & P(:)<=32767 );
if true
% code
end
for K = 47 : -1 : 1
petname = sprintf('PETWB001_PT%03d.dcm', K);
thisinfo = dicominfo(petname);
fn = fieldnames(thisinfo);
for N = 1 : length(fn)
thisfield = fn{N};
info(K).(thisfield) = thisinfo.(thisfield);
end
this_slice = dicomread(petname);
slices{K} = this_slice;
end
rescale_slopes = {info.RescaleSlope};
mask = cellfun(@isempty, rescale_slopes);
inrange_mask = cellfun(@(M) any(M(:) >= 32767 & M(:) <= 32767), slices);
idx_of_inrange = find(inrange_mask);
rescale_slope_of_inrange = rescale_slopes(inrange_mask);
rescale_slopes(mask) = {0}; %set missing entries to 0
rescale_slopes = cell2mat(rescale_slopes(:))
  댓글 수: 1
Rik
Rik 2018년 11월 1일
The slope and intercept in dicom are scan-specific settings, not specific per slice. So what you should do is load the entire scan to a single array, pick a data type that supports your later calculations and just do this:
IM=IM*info.RescaleSlope+info.RescaleIntercept;

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

답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by