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
Walter Roberson
2020년 5월 6일
It is not clear where it is getting FourierApp from? You are not passing in the app explicitly ?
Darren Miller
2020년 5월 6일
Darren Miller
2020년 5월 6일
편집: Darren Miller
2020년 5월 6일
Mohammad Sami
2020년 5월 6일
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
Mohammad Sami
2020년 5월 6일
편집: Mohammad Sami
2020년 5월 6일
You can also pass in the uiaxes itself, rather then the app
function externalfunc(a,b,c,uiax)
imshow(I,'parent',uiax);
end
Darren Miller
2020년 5월 6일
Mohammad Sami
2020년 5월 6일
You can specify the Parent property when calling imagesc
imagesc(C,'Parent',uiax)
Walter Roberson
2020년 5월 6일
or for many of the plotting routines you can pass the handle to the container object as the first parameter
imagesc(uiax, C)
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Display Image에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!