How to extract figure profile coordinates

Hello,
I am working on a substrate curvature driven tissue growth model.
I create a sinusoidal interface, evaluate the curvature of the profile at each point, evaluate the amount of tissue growth for each point (curvature dependent) at the current step and overwrite the figure showing the tissue deposited.
This is what I obtain, with "old" tissue painted in blue and growth tissue painted in red (no tissue growth where the curvature is negative):
Now I should repeat the process considering the new interface profile obtained after the tissue deposition.
How can I obtain the coordinates of the new profile points (as a 2D matrix) by this Figure keeping the same matrix size (199x199)?
I tried to use getframe but it acquires the profile with the screen resolution (much higer) and then I used the following code to extract the point coordinates:
binaryImage = BW < 1;
[rows, columns, numberOfColorChannels] = size(BW);
for c = 1 : columns
newprofile(c) = rows - find(binaryImage(:,c), 1, 'first') + 1;
end
This works but:
1) I don't know how to "rescale" it along both x and y axes.
2) The updated profile is not smooth (see next image) and that reflects on the curvature measurement in the following steps. I could extract the fitting law but I should still tackle the issue (1).
Thanks.

댓글 수: 2

DGM
DGM 2022년 7월 11일
How exactly is the plot being generated? If it's already a raster process, why not generate the working "image" in the workspace to begin with? Is that possible?
I generally suggest to consider figures as tools for visualization only, and to avoid using them as composition tools -- but I'm not sure if your case is one where it's easy to do that.
Hello DGM,
thank you for your help.
The blue plot is generated as a surf given the coordinates of the profile points, the red plot is generated adding to the plot rectangular markers parallel to the profile where line width is proportional to the grown tissue thickness (see the entire code below).
How can I generate the working image in the workspace? Creating an empty matrix with 0 when there is no tissue and 1 when there is tissue (old or grown tissue)? In this case how could I impose the tissue growth perpendicular to the profile?
Thank you for your suggestion, now I understand why and I'm willing to modify the code accordingly.
x=0:pi/100:2*pi;
y=1+sin(x);
profile=[x;y];
d1=diff(y);
curvature=diff(d1);
lenght=size(profile,2)-1;
x=x(1,2:lenght);
y=y(1,2:lenght);
xx=[x;x];
yy=[y;y];
zz=zeros(size(xx));
dd2=[curvature;curvature];
figure(4)
hs=surf(xx,yy,zz,dd2,'EdgeColor','interp');
area(x,y)
view(2)
axis([0.03 6.25 0 2])
title('interface')
hold on
for i=100:198
k=50;
thickness=((curvature(1,i)+curvature(1,i+1))/2)*k;
A = [profile(1,i),profile(2,i)];
B = [profile(1,i+1),profile(2,i+1)];
Clen = thickness/2;
AB = B - A;
AB = AB/norm(AB);
ABperp = AB*[0 -1;1 0];
ABmid = (A + B)/2;
D = ABmid - Clen*ABperp;
E=A-Clen*ABperp;
F=B-Clen*ABperp;
axis equal
LineWidth=thickness*200;
set(gca,'TickLength',[0 0])
plot([E(1,1) F(1,1)],[E(1,2) F(1,2)],'r','LineWidth',LineWidth)
end

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Exploration에 대해 자세히 알아보기

제품

질문:

2022년 7월 11일

댓글:

2022년 7월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by