matlab web app serverにてfigureが使えない時の対処法

2 Ansichten (letzte 30 Tage)
soh
soh am 18 Dez. 2022
Kommentiert: Kojiro Saito am 20 Dez. 2022
matlab web app serverにapp desingerを用いて作ったアプリをデプロイしました。
ただ、web app serverでは複数ウィンドウのアプリに対応していないということを知りました。
figureを用いてincropを使っていたりしますが、この場合はどうすればfigureを使わずに、incropが使えるのでしょうか。
rgb = imread(filename);
figure('Name','元画像','NumberTitle','off');
imshow(rgb);
[croppedImg,~] = imcrop(rgb);

Akzeptierte Antwort

Kojiro Saito
Kojiro Saito am 19 Dez. 2022
ドキュメントのimcrop(h)の方法が適用できます。imcropの入力引数にfigure、axes、uipanel、または image グラフィックス オブジェクトのハンドルが入れられるので、App Designerの座標軸(uiaxes)やパネル(uipanel)を指定すればFigureを使わずにクロップできます。
コールバックのサンプルです。ボタンクリック時に画像を選択し、1つ目の座標軸(app.UIAxes)に画像を表示し、imcropもこのapp.UIAxesを引数にして実行します。
function ButtonPushed(app, event)
[imgFile, imgPath] = uigetfile({'*.jpg;*.png'});
img = imread(fullfile(imgPath, imgFile));
imshow(img, 'Parent', app.UIAxes)
[croppedImg,~] = imcrop(app.UIAxes);
imshow(croppedImg, 'Parent', app.UIAxes2)
end
「共有」→「Webアプリ」で変換したCTFファイルをMATLAB Web App Serverに登録し、Webブラウザでアクセスした画面です。
imcropがuiaxesの中で実行されています。
右クリックして「イメージのトリミング」をクリックすると、クロップされた画像が右側のuiaxes (コードではapp.UIAxes2)に表示されています。
  8 Kommentare
soh
soh am 20 Dez. 2022
ありがとうございます。
無事解決いたしました。
原因は、toolboxが導入されていないのが問題でした。
お手数おかけいたしました。
次回以降は下記を参考に、一度toolboxの観点にて確認いたします。
https://jp.mathworks.com/matlabcentral/answers/326490-toolbox
Kojiro Saito
Kojiro Saito am 20 Dez. 2022
ご連絡ありがとうございます。無事に解決して良かったです。

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Web アプリ finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!