Y-axis flip issue - Matlab App designer GUI

Viewed 188

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

2 Answers

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';

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

Related