Y-axis flip issue - Matlab App designer GUI
Asked Answered
S

2

6

Based on this question Calculate Y coordinates of an image from graph point of origin I tried to do the same in app designer GUI but it does not work. I attached an image that shows that the image does not start from graph point of origin and that I get a new figure due to the set command. Any idea how to fix/do it?

Code:

function ButtonPushed(app, event)
    url='https://icons.iconarchive.com/icons/thesquid.ink/free-flat-sample/512/owl-icon.png';

    I = imread(url);
    I = rgb2gray(I);
    I=flipud(I);
    
    imshow(I,'Parent', app.imageAxes); 
    set(gca,'YDir','normal')
end

enter image description here

Sapowith answered 24/12, 2021 at 11:59 Comment(0)
S
6

gca creates a new figure window and a new set of axes if there are none. In particular, the app designer window is not a figure window, and so a new one is created.

But you don’t need to use gca to get a reference to your axes, since you already have the reference in app.imageAxes. This will set your axes to have a normal orientation:

set(app.imageAxes, ,'YDir', 'normal')

This should be the same as

app.imageAxes.YDir = 'normal';
Selfassurance answered 27/12, 2021 at 15:4 Comment(0)
B
1

you could try to import the image data as a 2-dimensional grid, and then flipping it.. could work not sure.

Benzo answered 26/12, 2021 at 17:5 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Cribble

© 2022 - 2024 — McMap. All rights reserved.