Code covered by the BSD License  

Highlights from
Dicom Operator - EsmeProcess

image thumbnail

Dicom Operator - EsmeProcess

by

 

06 Sep 2013 (Updated )

EsmeProcess functions dicom image operation including viewing, drawing, writing and statistic.

[meanGL1, stdGL1, meanGL2, stdGL2, ...
function [meanGL1, stdGL1, meanGL2, stdGL2,                             ...
    mx1,     mn1,    mx2,     mn2,                                      ...
    sk1,     ku1,    sk2,     ku2]                                      ...
    = stat1(imageGray, binaryImage, maxA, minA, newmax, newmin, steps)
%--------------------------------------------------------------------------
% stat1: Calculate the means and deviations of the whole image and the ROI,
% with a normalization process from range [minA, maxA] to [newmin, newmax]
% where, imageGray = image; binaryImage = mask
%
%   Usage: [meanGL1, stdGL1, meanGL2, stdGL2, mx1, mn1, mx2, mn2] =     ...
%                                                stat1(                 ...
%                                                imageGray,             ...
%                                                binaryImage,           ...
%                                                maxA, minA,            ...
%                                                newmax, newmin,        ...
%                                                steps)
%
% Defined variables:
%   meanGL1:   mean of imageGray (whole image)
%   stdGL1:    standard deviation of imageGray (whole image)
%   mx1, mn1:  maximun and minimum value of normalized imageGray
%   sk1, ku1:  skewness and kurtosis of normalized imageGray respectively
%   meanGL2:   mean of ROI
%   stdGL2:    standard deviation of ROI
%   mx2, mn2:  maximun and minimum value of normalized ROI
%   sk2, ku2:  skewness and kurtosis of normalized ROI
%
%   imageGray: the gray image
%   binaryImage:   the mask
%   maxA, minA:   imageGray is under the range of [minA, maxA]
%   newmax, newmin: normalized imageGray is under the range
%   steps: divisions of the new normalized image value
%--------------------------------------------------------------------------

imageGray = normalize(imageGray, maxA, minA, newmax, newmin, steps);

meanGL1     = mean2(imageGray);
stdGL1      = std2(imageGray);
[r, c]      = size(imageGray);
A           = reshape(imageGray, r*c, 1);

if(isempty(A))
    mx1 = NaN;
    mn1 = NaN;
    sk1 = NaN;
    ku1 = NaN;
else
    mx1 = max(A);
    mn1 = min(A);
    sk1 = skewness(hist(A, steps));
    ku1 = kurtosis(hist(A, steps));
end

if(isempty(binaryImage))
    meanGL2 = NaN;
    stdGL2 = NaN;
    mx2 = NaN;
    mn2 = NaN;
    sk2 = NaN;
    ku2 = NaN;
else
    binaryImage = logical(binaryImage);
    meanGL2     = mean(imageGray(binaryImage));
    stdGL2      = std(single(imageGray(binaryImage)));
    [r, c]      = size(imageGray(binaryImage));
    A           = reshape(imageGray(binaryImage), r*c, 1);
    if(isempty(A))
        mx2 = NaN;
        mn2 = NaN;
        sk2 = NaN;
        ku2 = NaN;
    else
        mx2 = max(A);
        mn2 = min(A);
        %sk2 = skewness(A);
        %ku2 = kurtosis(A);
        
        %Please be aware that the steps is different from 1:steps,
        %which is the xcenters. if there is any change from steps to
        %1:steps here, the drawhist.m also needs change correspondingly
        sk2 = skewness(hist(A, steps));
        ku2 = kurtosis(hist(A, steps));
    end
end

end

Contact us