フィルターのクリア

so in appdesigner im building a list box to turn the image to (red ,blue ,green) this is my code for it bout it wont run

1 回表示 (過去 30 日間)
jana
jana 2023 年 1 月 13 日
編集済み: Jan 2023 年 1 月 13 日
value = app.ListBox.Value;
if value== 'Red'
a=(app.Image);
red=a;
red(:,:,2:3)=0
setappdata(0,'filename',red);
setappdata(0,'imrotation',red);
I=imshow(red,'parent',app.UIAxes2,...
'XData',[1 app.UIAxes2.Position(3)],...
'YData',[1 app.UIAxes2.Position(4)]);
app.UIAxes2.XLim=[0 I.XData(2)];
app.UIAxes2.YLim=[0 I.YData(2)];
else if value== 'Blue'
Agray=im2gray(app.Image);
zerochan = zeros(size(Agray),class(Agray));
blue = cat(3,zerochan,zerochan,Agray);
setappdata(0,'filename', blue);
setappdata(0,'imrotation', blue);
I=imshow(blue,'parent',app.UIAxes2,...
'XData',[1 app.UIAxes2.Position(3)],...
'YData',[1 app.UIAxes2.Position(4)]);
app.UIAxes2.XLim=[0 I.XData(2)];
app.UIAxes2.YLim=[0 I.YData(2)];
else
Agray=im2gray(app.Image);
zerochan = zeros(size(Agray),class(Agray));
green = cat(3,zerochan,Agray,zerochan);
setappdata(0,'filename',green);
setappdata(0,'imrotation',green);
I=imshow(green,'parent',app.UIAxes2,...
'XData',[1 app.UIAxes2.Position(3)],...
'YData',[1 app.UIAxes2.Position(4)]);
app.UIAxes2.XLim=[0 I.XData(2)];
app.UIAxes2.YLim=[0 I.YData(2)];
end
end
end
  1 件のコメント
Jan
Jan 2023 年 1 月 13 日
編集済み: Jan 2023 年 1 月 13 日
Please do not post code as screenshots, but as text. Then it can be used to create an answer with copy&paste.
This is not twitter: No # before the tags. Thanks.

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

回答 (1 件)

Kevin Holly
Kevin Holly 2023 年 1 月 13 日
Based on the red squiggly line under Methods in your screenshot, you may have an extra "end" in your code.
  2 件のコメント
jana
jana 2023 年 1 月 13 日
i fixedit but then this popped up
Kevin Holly
Kevin Holly 2023 年 1 月 13 日
Use strings instead of character arrays for your if conditions
if value == "Red"
The size was causing issues. See difference of size between character and string arrays below.
Character array:
size('Red')
ans = 1×2
1 3
String array:
size("Red")
ans = 1×2
1 1

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

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by