Surface roughness and gaussian filtering

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

 採用された回答

Image Analyst
Image Analyst 2020 年 6 月 22 日

0 投票

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

7 件のコメント

Doyinsola Oduwole
Doyinsola Oduwole 2020 年 6 月 22 日
Thank you.
Image Analyst
Image Analyst 2020 年 6 月 22 日
Did that solve the problem? If so, can you "Accept this answer"? Thanks in advance.
NGUEUKO  Francis Darryl
NGUEUKO Francis Darryl 2021 年 8 月 23 日
when i do this i get
Undefined function or variable 'gauss'.
please why is this
Image Analyst
Image Analyst 2021 年 8 月 23 日
@NGUEUKO Francis Darryl Because you most likely altered the code I posted. I just copied and pasted it into an m-file in the editor and it ran perfectly fine. Attach your m-file with the paper clip icon so I can see how you altered it if you still need more help.
NGUEUKO  Francis Darryl
NGUEUKO Francis Darryl 2021 年 8 月 23 日
NGUEUKO  Francis Darryl
NGUEUKO Francis Darryl 2021 年 8 月 23 日
@Image Analysti still need more help sir, thanks.
couldnot attach my m.file
Image Analyst
Image Analyst 2021 年 8 月 23 日
Why not? Did you use the paperclip icon? It should let you attach the m-file.
Why does the code appear in the command window also? Did you have "echo on" or did you paste it there?
How did you try to run demo.m? Did you click the green run triangle on the toolbar? That should run and have no errors.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by