gray image app design

13 Ansichten (letzte 30 Tage)
Shu-An Hsieh
Shu-An Hsieh am 21 Sep. 2021
Kommentiert: Image Analyst am 22 Sep. 2021
I am trying to convert and display the gray image from the left green image into the right one. However, the gray image will pop up separately instead of inside the app. Hope someone can help soon. Thank you!
  1 Kommentar
Rik
Rik am 21 Sep. 2021
You should teach yourself the habit of specifying the parent every time you create a graphics object. In this case you create an axes without specifying the parent, so that will probably create a new axes object in a normal figure, instead of creating one in your uifigure.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
Image Analyst am 22 Sep. 2021
Try getting rid of the ax=axes line. That probably makes a new axes, which you don't need or want since you created them all already in App Designer.
  2 Kommentare
Shu-An Hsieh
Shu-An Hsieh am 22 Sep. 2021
Bearbeitet: Image Analyst am 22 Sep. 2021
I got this error after I removed it.
Image Analyst
Image Analyst am 22 Sep. 2021
rgb2gray takes an image, not a filename. Try
rgbImage = imread(fileName);
% Get the dimensions of the image.
% numberOfColorChannels should be = 1 for a gray scale image, and 3 for an RGB color image.
[rows, columns, numberOfColorChannels] = size(rgbImage)
if numberOfColorChannels > 1
% Convert from RGB to gray scale.
grayImage = rgb2gray(rgbImage);
else
% It's already a gray scale image.
grayImage = rgbImage;
end
imshow(rgbImage, 'Parent', app.UIAxes3);
imshow(grayImage, 'Parent', app.UIAxes2);

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Develop uifigure-Based Apps finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by