필터 지우기
필터 지우기

Calculating Surface Curvature from Image Data

조회 수: 26 (최근 30일)
Leon Stan
Leon Stan 2024년 6월 4일
댓글: Mathieu NOE 2024년 7월 9일 12:14
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일 11:33
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일 12:14
thanks !

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by