Hi. I am new to MATLAB and Im still learning about GUI. How can I transfer image from one gui to another?

2 件のコメント

Ramon Ticzon
Ramon Ticzon 2019 年 3 月 1 日
編集済み: Ramon Ticzon 2019 年 3 月 1 日
I want to copy the image (first image) that is from my GUI1 to the first axes of my GUI2. (second image). Also, is it possible to retain the area of pixels that was stored in array from the first selection?
Ramon Ticzon
Ramon Ticzon 2019 年 3 月 1 日
I used this example code to select the part of the image. How can I transfer both the image and the selected pixels to another GUI so that I can go and proceed to mask the image on the second GUI. Thanks!
imtool close all; % Close all figure windows created by imtool.
baseFileName = 'onion.png';
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
% Check if file exists.
rgbImage = imread(fullFileName);
imshow(rgbImage, []);
axis on;
% Ask user to draw freehand mask.
message = sprintf('Left click and hold to begin drawing.\nSimply lift the mouse button to finish');
uiwait(msgbox(message));
hFH = imrect();
binaryImage = hFH.createMask();
xy = hFH.getPosition;
subplot(2, 2, 1);
imshow(rgbImage, []);
axis on;
drawnow;

サインインしてコメントする。

 採用された回答

Walter Roberson
Walter Roberson 2019 年 3 月 1 日
編集済み: Walter Roberson 2019 年 3 月 1 日

0 投票

  • You can set the Parent property of the containing axes to be the container (such as a figure or uipanel) that the image is to be moved to. It is not well defined whether this will also move any associated colorbar and legend(). It will disappear from the original location. If a colormap has been set for the individual axes, then the colormap will be moved as well, but if the colormap was set against the figure then the colormap will not be moved. Color axes mapping information will be moved (that is, the information about which numeric value in the image is to map to the "first" color, and which numeric value is to map to the "last" color.) This requires that the data has already been created as an image object.
  • You can find the handle of the image and set its Parent property to the axes or hgtransform that the image is to be moved to. It will disappear from the original location. This will not move any associated colorbar or legend. The colormap will not be moved. Color axes mapping information will not be moved. This requires that the data has already been created as an image object.
  • For either of the above two, instead of setting the Parent property, you can copyobj() to the destination container. This would make a duplicate copy: it will not disappear from the original location. It is not well defined whether this would also copy any associated colorbar and legend(). Color axes mapping information would be transferred for the case of copyobj() of the axes, but not for the case of copyobj() of the image object. This requries that the data has already been created as an image object.
  • You can find the handle of the image and get its CData property and find the handle of the place that is to contain the image, and image() or imshow() or imagesc() to the destination. It will not disappear from the original location. Any associated colorbar and legend will not be copied. Any colormap will not be copied. Color axes mapping information will not be transfered. This requires that the data has already been created as an image object.
  • You can save a copy of the data in some convenient place (possibly guidata) and find the handle of the place that is to contain the image, and image() or imshow() or imagesc() to the destination. It will not disappear from any original location. Any associated colorbar and legend wil not be copied. Any colormap will not be copied. Color axes mapping information will not be transfered. This does not require that the data has already been created as an image object. More on sharing data

1 件のコメント

Ramon Ticzon
Ramon Ticzon 2019 年 3 月 1 日
Thanks. I'm trying to understand it. An example will be a great help to understand it better. Can u provide some useful codes?

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2019 年 3 月 1 日

0 投票

See the bottom part of this FAQ entry: Click here for the FAQ
Also see Geoff's answer: Geoff's code

カテゴリ

ヘルプ センター および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by