フィルターのクリア

How to clear images in app designer

21 ビュー (過去 30 日間)
Othman Alkandri
Othman Alkandri 2023 年 2 月 1 日
編集済み: Othman Alkandri 2023 年 2 月 2 日
Hello guys,
I am trying to clear the image when I click the reset button. I tried the following two commands.
clf(app.Image3)
cla(app.Image3, 'reset')
Do you recommend other commands to use?

採用された回答

Image Analyst
Image Analyst 2023 年 2 月 1 日
clf clears a whole figure, not just one axes on the figure. It clears everything I believe. So, since that is never anything I want to do I never use it.
cla clears just the current axes or the one you told it to. I use this one a lot because I want to make sure the axes gets cleared. Often I put "hold on" to draw graphics in the overlay and forget to turn it off. If you don't call cla then display a new image, it will just add to the axes and be on top covering everything that was there before. If you do that enough, like dozens or hundreds of times, your memory will get exhausted and your program will get slower and slower.
  4 件のコメント
Image Analyst
Image Analyst 2023 年 2 月 2 日
Here is one way. You can set the ImageSource to a small white image of whatever color you want.
% Button pushed function: DisplayImageButton
function DisplayImageButtonPushed(app, event)
% Get selected filename from listbox.
selectedFileName = app.ListBox.Value;
if isempty(selectedFileName)
return;
end
% Display image in the axes control.
theImage = imread(selectedFileName);
imshow(theImage, 'Parent', app.UIAxes);
% Display image in the "Image" control.
app.Image.ImageSource = theImage;
end
% Button pushed function: ClearImagesButton
function ClearImagesButtonPushed(app, event)
cla(app.UIAxes, 'reset'); % Clear axes control.
app.Image.ImageSource = 255*ones(2,2,3); % Clear image control.
end
See attached demo.
Othman Alkandri
Othman Alkandri 2023 年 2 月 2 日
編集済み: Othman Alkandri 2023 年 2 月 2 日
thank you, I like the idea of setting the ImageSource to a small white images

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Processing and Computer Vision についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by