Matlab adds additional margin to an image!

3 visualizaciones (últimos 30 días)
Amin Tabrizian
Amin Tabrizian el 28 de Mayo de 2019
Comentada: Amin Tabrizian el 30 de Mayo de 2019
I'm going to develope an app for calculating beam deflections. for inserting images of supports, when I insert the images matlab automatically adds unwanted margins to my pictures.Does anyone know how can I solve this issue?
Screen Shot 2019-05-28 at 10.15.35 PM.png
  2 comentarios
Geoff Hayes
Geoff Hayes el 29 de Mayo de 2019
Amin - are the "unwanted" margins the space between the triangles and the green rectangle? Are you showing/drawing these objects in one axes or more? Please clarify.
Amin Tabrizian
Amin Tabrizian el 29 de Mayo de 2019
Dear Geoff,
Thank you for your response. I will upload another image to show exactly what the problem is.Screen Shot 2019-05-29 at 9.35.07 PM.png
Here the gray margins around the right triangle is what I meant which doesn't exist in the original file of the image.
Here is the code which I've written on the Button:
% Button pushed function: Button
function ButtonPushed(app, event)
fig = app.UIFigure;
ax = uiaxes(fig,'position',[78 120 240 240]);
imshow('Support1.png','parent',ax);
ax = uiaxes(fig,'position',[220 120 240 240]);
imshow('Support1.png','parent',ax);
end
end
And file of Support1.png is attached to this comment!
Thanks!

Iniciar sesión para comentar.

Respuesta aceptada

Geoff Hayes
Geoff Hayes el 29 de Mayo de 2019
Amin - from your code
ax = uiaxes(fig,'position',[78 120 240 240]);
imshow('Support1.png','parent',ax);
ax = uiaxes(fig,'position',[220 120 240 240]);
isn't the first axes created at x-coordinate 78 with a width of 240? So that would mean that 78+240=318...but the second axes is created at x-coordinate 220 which is less than 318 which leads to overlap amongst the two axes. Maybe you need to create the second axes at least at x-coordinate 318 so that there is no overlap between the two.
  3 comentarios
Geoff Hayes
Geoff Hayes el 30 de Mayo de 2019
Ali - why not just concatenate the two images together and then put on the same axes? Something like
ax = uiaxes(fig,'position',[78 120 240 240]);
myImage = imread('Support1.png');
myImageX2 = [myImage myImage];
imshow(myImageX2, 'parent', ax);
Of course, you will need to adjust the width and position of the axes to support this new image whose width (number of columns) is twice what it was.
Amin Tabrizian
Amin Tabrizian el 30 de Mayo de 2019
Geoff,
Thanks a lot. It works!
Screen Shot 2019-05-30 at 8.51.46 PM.png

Iniciar sesión para comentar.

Más respuestas (1)

Walter Roberson
Walter Roberson el 29 de Mayo de 2019
uiaxes() with 'position' places according to the inner position property, not according to the outer position property.
If you set the second axes Visible property on, the labels will appear, and it will be obvious that the blank space is exactly where the labels would be, in the area between the inner position and the outer position.
Traditional axes are not exactly the same. With traditional axes, when you turn the axes visibility off, the layout routine is re-run and the visible area expands to (closer to) the outer position. You would get overlap because your position overlap, but it would be clearly defined and obvious as to what had happened.
(If you do the experiment with traditional axes() remember to set the Units to Pixels as the default is normalized.)
  1 comentario
Amin Tabrizian
Amin Tabrizian el 29 de Mayo de 2019
Editada: Amin Tabrizian el 29 de Mayo de 2019
Thanks. I completely understand the problem. But still I don't know how can I solve this issue. Please look at the comment I've written to Geoff Hayes:

Iniciar sesión para comentar.

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by