showing the histogram in UIAxes_2 And not separately in the application

1 回表示 (過去 30 日間)
rama
rama 2022 年 12 月 17 日
回答済み: Walter Roberson 2022 年 12 月 17 日
my code:
global a;
global input;
input=im2gray(a);
imhist(input);
imshow(input,'Parent',app.UIAxes_2);

採用された回答

Walter Roberson
Walter Roberson 2022 年 12 月 17 日
imhist() does not have any possibility of passing in an an axes.
You will need to use the form of imhist() with outputs, and then draw the results. Something like
a = app.a;
app.gray_a = im2gray(a);
[counts, locations] = imhist(app.gray_a);
imshow(app.gray_a, 'Parent', app.UIAxes_2);
hold(app.UIAxes_2, 'on');
bar(locations, counts, 'Parent', app.UIAxes_2);
hold(app.UIAxes_2, 'off');
Notice the lack of global variables. Using global variables in App Designer is most often... misguided...

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeHistograms についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by