Calculating Surface Curvature from Image Data

18 ビュー (過去 30 日間)
Leon Stan
Leon Stan 2024 年 6 月 4 日
コメント済み: Mathieu NOE 2024 年 7 月 9 日
Hello,
I'm trying to calculate the curvature of each surface point from a morphology picture. However, when using surfature(), I do not get the results I want. A lot of points have a gaussian curvature of 0, which is not plausible for the example I use.
I tried a lot of different methods for calculating and ploting, but never got a good result...
I wrote the following:
% reading in picture
data = imread("Morphology.PNG");
% if not yet, convert to gray image
if size(data, 3) == 3
data = rgb2gray(data);
end
% smoothing image
data = imgaussfilt(data, 4);
% converting to double
data = double(data);
z = data;
% generating 2D arrays for X and Y with size of data-dimensions
[Rows, Cols] = size(data);
[x, y] = meshgrid(1:Cols, 1:Rows);
% calculating gaussian and normal curvature
[K, H] = surfature(x, y, data);
% display surface
figure;
surf(x, y, z, "EdgeColor","none");
title('Surface Morphology');
colorbar;
% ploting the results
figure;
surf(x, y, z, K, "EdgeColor","none");
title('3D Surface Gaussian Curvature Map');
colorbar;
disp(K);

採用された回答

Mathieu NOE
Mathieu NOE 2024 年 6 月 5 日
hello
I think this is because your K array contains some high amplitude spikes that avoid you see the smaller amplitude signals
so I decide to scale the imagesc (and not surf) plot using the mean of abs(K) as a starting point (then you can also add another scaling factor from there) and then the K plot shows up correctly
as I don't have the Image Processing Tbx , I replaced imgaussfilt with a Fex submission (smooth2a) but that is secondary in the problem - you can of course use imgaussfilt on your side as you did in the first place
this is my K plot so far :
code updated :
% reading in picture
data = imread("Morphology.png");
% if not yet, convert to gray image
if size(data, 3) == 3
data = rgb2gray(data);
end
% smoothing image
% data = imgaussfilt(data, 4); % you
% converting to double
data = double(data);
% smoothing image
data = smooth2a(data,10,10); % me
% generating 2D arrays for X and Y with size of data-dimensions
[Rows, Cols] = size(data);
[x, y] = meshgrid(1:Cols, 1:Rows);
% calculating gaussian and normal curvature
[K, H] = surfature(x, y, data);
% display surface
figure;
imagesc(data);
title('Surface Morphology');
colorbar;
% ploting the results
figure;
imagesc(K);
K_mean = mean(abs(K),'all');
amplitude = 3*K_mean; % eventually apply a scaling factor to K_mean
caxis([-amplitude amplitude]);
title('3D Surface Gaussian Curvature Map');
colorbar;
  5 件のコメント
Leon Stan
Leon Stan 2024 年 7 月 9 日
Hello again, I'm new to the forum, so I did'nt know thats a thing :)
I accepted your answer!
Mathieu NOE
Mathieu NOE 2024 年 7 月 9 日
thanks !

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by