Search code examples
matlabgaussiansmoothing

How to do smoothing of 3D images based on millimeter?


I am simulating a paper that the scale of smoothing of images is based on millimeter. The format of 3D images is DICOM. For example, normally the smoothing of image X with window size and scale s, is being done as follows:

f1 = fspecial('gaussian',[size,size],s);
Smooth1 = imfilter(X,f1);

Does anybody know how can I do smoothing which its scale is based millimeter?

Should I change the size of window based on millimeter instead of pixel? How can I do this?


Solution

  • If you want the shape of the Gaussian filter to be defined in millimeters, you can use the PixelSpacing property from the DICOM metadata to convert millimeters to pixels. The units of the PixelSpacing is mm/pixel

    info = dicominfo(filename);
    X = double(dicomread(info));
    
    scale_mm = 3;                                           % Signma of the filter in mm
    
    scale_px = scale_mm / double(info.PixelSpacing(1));     % Converted to pixels
    
    % Create a Gaussian filter using this sigma value
    f1 = fspecial('gaussian', [height, width], scale_px);
    
    % Apply the smoothing
    smooth1 = imfilter(X, f1);