Plotting in GUI from an external function using imagesc()

So I've got an image file loaded in using image = imread(app.ImageName) and I am trying to send it off to an external function to do a fourier transform on it then show it on the gui using imagesc..
How do I use imagesc in a way that might be similar to imshow(img,'parent',app.UIaxes)??
Just to see if I could get something working, I also tried using imshow(img,'parent',app.UIaxes) within this external function to see if I could plot to the gui using that and it is not working either... giving me an error. I need to use imagesc but figured I'd mess around with imshow to see if I could get anything working. Heres whats happening
in GUI:
app.baseImg = imread(app.Input);
imshow(app.baseImg,'Parent',app.UIAxes)
doFourier(app.baseImg,app.RunMode,app.flareAngle,app.stepSize) %calls external function doFourier.m, plugging in the image
in external function, doFourier.m:
imshow(I,'parent',FourierApp.UIAxes2); %I is a modified image of the input image, app.baseImg
and heres the error it is giving me
The property 'UIAxes2' in class 'FourierApp' must be accessed from a class instance because it is not a Constant property.
Error in doFourier (line 5)
imshow(I,'parent',FourierApp.UIAxes2);
EDIT: If I tyoe
FourierApp()
before the imshow() in doFourier it works because it calls the class or something, but then it opens up another instance of the app... I need to call the class somehow at the beginning of the external function so that I can use it to modify things in the FourierApp class.

8 Kommentare

It is not clear where it is getting FourierApp from? You are not passing in the app explicitly ?
FourierApp is the name of the app I am making, and the function doFourier is a function which exists in the same directory.
OK I see what you mean now.. I need to pass in the app into the function correct? How do I do that?
I tried typing
FourierApp();
at the beginning of the doFourier external function but then it opens a new instance of the app. It does work though, allowing me to use imshow() to put the image on the axes (UIaxes2) in the GUI!
You need to pass it in when you are calling the function. It should not be created inside the external function.
function externalfunc(a,b,c,app)
% UIAxes2 must be a public property in the FourierApp
imshow(I,'parent',app.UIAxes2);
end
You can also pass in the uiaxes itself, rather then the app
function externalfunc(a,b,c,uiax)
imshow(I,'parent',uiax);
end
Ahh thanks Walter and Mohammad.. I totally see now. I moved the external function in the app for convenience and followed your instructions and it is working now.
Now, any idea how to use imagesc to plot on a specific axes?? I need to do something like the imshow(I,'parent',uiaxes2) but with imagesc. Is that possible?
You can specify the Parent property when calling imagesc
imagesc(C,'Parent',uiax)
or for many of the plotting routines you can pass the handle to the container object as the first parameter
imagesc(uiax, C)

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Display Image finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 5 Mai 2020

Community Treasure Hunt

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

Start Hunting!

Translated by