Adding line change the size of the image

1 回表示 (過去 30 日間)
Aurélie B
Aurélie B 2021 年 5 月 6 日
コメント済み: Aurélie B 2021 年 5 月 6 日
Hi!
I am currently working on adding lines above a image in App Designer, but when I add these lines, the image changes size and I don't want it to. Can someone help me please?
M is a 4D matrix(160,130,26,14)
profondeur, hauteur, largeur, temps are sliders, and angle 1,5 are knob
I=M(:,:,floor(profondeur),floor(temps));
affichagelignex(app);
J=imresize(I,[160 130]);
imshow(J,[],'Parent',app.UIAxes);
function affichagelignex(app)
profondeur = app.zaxegauchedroiteSlider.Value;
hauteur = app.yaxeavantarrireSlider.Value;
largeur = app.xaxepiedstteSlider.Value;
angle1 = app.AngleXYKnob.Value;
angle5 = app.AngleXZKnob.Value;
persistent h1
persistent h5
if (isempty(h1)&& isempty(h5))
h1=line(app.UIAxes,[0 130],[largeur largeur],'Color','green');
h5=line(app.UIAxes3,[0 26],[largeur largeur],'Color','green');
else
h1=line(app.UIAxes,[0 130],[largeur-hauteur*tand(angle1) largeur+(130-hauteur)*tand(angle1)],'Color','green');
h5=line(app.UIAxes3,[0 26],[largeur-profondeur*tand(angle5) largeur+(26-profondeur)*tand(angle5)],'Color','green');
end

回答 (1 件)

Chad Greene
Chad Greene 2021 年 5 月 6 日
Can you get the axis limits before plotting the lines, and then set the axis back to those limits afterwards? Something like this:
ax = axis; % GET THE AXIS LIMITS
if (isempty(h1)&& isempty(h5))
h1=line(app.UIAxes,[0 130],[largeur largeur],'Color','green');
h5=line(app.UIAxes3,[0 26],[largeur largeur],'Color','green');
else
h1=line(app.UIAxes,[0 130],[largeur-hauteur*tand(angle1) largeur+(130-hauteur)*tand(angle1)],'Color','green');
h5=line(app.UIAxes3,[0 26],[largeur-profondeur*tand(angle5) largeur+(26-profondeur)*tand(angle5)],'Color','green');
end
axis(ax) % SET THE AXIS LIMITS
  10 件のコメント
Chad Greene
Chad Greene 2021 年 5 月 6 日
Good heavens. I'm sorry, we've reached the end of my ideas for troubleshooting. Hopefully someone with app designing experience can chime in with better ideas. Good luck!
Aurélie B
Aurélie B 2021 年 5 月 6 日
Thank you so much for helping me :)

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

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by