Image displayed in GUI is tilted and not straight

1 visualizzazione (ultimi 30 giorni)
Hey,
I have displayed an image in GUI and at the start it is displayed fine. (MATLAB app designer)
After some number of running it started to be displayed titlted:
And this is the code that I used:
global im;
[rawname, rawpath] = uigetfile({'*.Jpg'},'Select Image Data');
fullname = [rawpath rawname];
ax = app.UIAxes1;
im = imread(fullname);
[~, ~, c] = size(im);
if c ~= 1
im = rgb2gray(im);
end
im = imresize(im,[256 256]);
imshow(im, 'parent', ax);
Is there some code that I need to add in order for the image to be displayed straight and not tilted always?
Thank you.
  4 Commenti
daniel cohen
daniel cohen il 30 Mag 2022
@Image Analyst Sorry for the inconvenience,
Here is the JPG file of the image that I used:
Also attaching the .mlapp file
The output the I'm getting is:
UIAxes3 (Radon transform of log spectrum FFT image at 0 to 180 degrees) suppused to be a 3D mesh.
UIAxes4 (Radon transform of log spectrum FFT image at Estimated phase) suppused to be a 2D plot.
UIAxes5 (Gabor filter) suppused to be a 3D mesh.
They all get tilted for some reason.
Thank you for the help.

Accedi per commentare.

Risposte (1)

Walter Roberson
Walter Roberson il 30 Mag 2022
You initialize each of your UIAxes with a CameraPosition.
When you call imshow(), passing in the axes (which is done properly), imshow() calls image(), and image puts the image up on the screen. At that point, the default axes view of [0 90] is in effect, which is what we would expect. But.. (at least while debugging), as soon as image() returns to imshow(), the axes View property has changed to -135 89.94140625 . There is no explicit call that is setting the View: it is magically changing upon return from image()
Eventually you get to the view(ax, 2) ... and nothing happens when that is called: ax.View stays exactly the same as above.
But if you put a breakpoint in at the view(ax,2) call and run to there, then the view(ax,2) call does work properly... and when it does, the axes CameraPosition changes dramatically to about [150 150 2100] replacing the [0.5 0.5 9] that you initialized the UIaxes to.
The work-around appears to be to add
drawnow()
before the view(ax,2) command.
  5 Commenti
daniel cohen
daniel cohen il 30 Mag 2022
I was talking about those plots that I have in the GUI, they are not displayed properly.
UIAxes3 and UIAxes5 need to be displayed as a 3D mesh
and UIAxes4 is displaying not on all the space that the plot have.
Thenk you.
Walter Roberson
Walter Roberson il 30 Mag 2022
UIAxes3 and UIAxes5 are already being displayed as 3D meshes. UIAxes3 looks like s surface plot instead of a mesh because the edges are close together due to the mesh being 367 by 181 and the Position not being much larger -- the edges pretty much touch in that window.
The Position properties of UIAxes3 and UIAxes4 stay the same during execution -- the code is not somehow making the Position larger or moving them. But UIAxes3 is getting drawn too large, drawn outside the box one would expect. Clipping appears to be on properly. UIAxes3 is getting drawn too large first, drawn down into the space one would expect for UIAxes4. Then after that, UIAxes4 is getting drawn too low down but is stopping half-way up the screen. But because UIAxes3 is drawn too big (for unknown reasons yet), UIAxes4 is getting drawn part way over top of UIAxes3's plot.
I think you are having problems with the CameraPosition that you are setting when the axes are created. I think you should not be setting those, and instead leaving them on automatic mode.

Accedi per commentare.

Categorie

Scopri di più su Image Processing Toolbox in Help Center e File Exchange

Prodotti


Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by