MATLAB: Surface roughness and gaussian filtering

image analysisimage processingImage Processing Toolboxroughness;

I'm trying to measure surface roughness from an image. I want to carry out gaussian filtering and according to literature, gaussian filtering gives the waviness profile and subtracting the waviness from the primary profile would give the roughness profile.
Does imgaussfilt work in the same way? I obtained a filtered image and then going on to subtract gives me a black image.
function gauss
I = imread('/Users/doyindav/Desktop/qualitymap.bmp');
sigma = 1;
%cutoff = 0.08;
h = imgaussfilt(I,'Filtersize',sigma);
new_image = imsubtract(I,h);
montage([I,new_image])
end

Best Answer

Your blur wasn't big enough, plus your difference values were all zero because you didn't blur it enough. This works:
% grayImage = imread('/Users/doyindav/Desktop/qualitymap.bmp');
grayImage = imread('moon.tif'); % Demo image.
subplot(1, 3, 1);
imshow(grayImage);
[blurredImage, subtractedImage] = gauss(grayImage);
subplot(1, 3, 2);
imshow(blurredImage);
subplot(1, 3, 3);
imshow(subtractedImage, []);
function [blurredImage, new_image] = gauss(grayImage)
sigma = 15;
%cutoff = 0.08;
blurredImage = imgaussfilt(grayImage,'Filtersize', sigma);
new_image = imsubtract(grayImage, blurredImage);
end
Related Question