(??? Undefined function or variable 'imshow

Hello everyone, I need some help. I am trying to change the colour of an image but got this error(??? Undefined function or variable 'imshow'.) below is the code; Meanwhile I don't the Image Processing Tool Box License. Is there any other way.
A=imread('C:\Users\sanni.2020\Desktop\cow.jpg','jpg');
A=image();
A= repmat(double(A)./255,[1 1 3]);
s=input('input color:');
if (strcmp(s,'red')==1)
A(:,:,2)=0;
A(:,:,3)=0;
elseif (strcmp(s,'green')==1)
A(:,:,1)=0;
A(:,:,3)=0;
elseif (strcmp(s,'blue')==1)
A(:,:,1)=0;
A(:,:,2)=0;
end
imshow();
hold off
end
input color:'red';
??? Undefined function or variable 'imshow'.

4 件のコメント

KSSV
KSSV 2021 年 3 月 16 日
You can try using image or pcolor.
Walter Roberson
Walter Roberson 2021 年 3 月 16 日
Which MATLAB version are you using? In old enough matlab, imshow was part of the Image Processing Toolbox
Philips Sanni
Philips Sanni 2021 年 3 月 16 日
Matlab version 7.9.0 (R2009b) version. There is no image processing toolbox
Philips Sanni
Philips Sanni 2021 年 3 月 16 日
@KSSV Just tried it. Another error pops out
??? Error using ==> surface
CData must be an M-by-N matrix or M-by-N-by-3 array
Error in ==> pcolor at 71
hh = surface(zeros(size(x)),x,'parent',cax);

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

回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 3 月 16 日

0 投票

In R2009b, imshow() was part of the Image Processing Toolbox. As you do not have that toolbox, you will not be able to use imshow()
I recommend that you use
image(A)

3 件のコメント

Philips Sanni
Philips Sanni 2021 年 3 月 16 日
I tried image(A)
This error came up ??? Subscript indices must either be real positive integers or logicals.
Walter Roberson
Walter Roberson 2021 年 3 月 16 日
Somewhere in your code, you assign a value to a variable named image -- or perhaps you did that at some point in the past and have not cleared your variables since then.
Also, you currently have
A=imread('C:\Users\sanni.2020\Desktop\cow.jpg','jpg');
A=image();
s legal, but it will completely replace the the cow image you read in, replacing it with a graphics object handle to the default image.
Walter Roberson
Walter Roberson 2021 年 3 月 16 日
A = imread('cameraman.tif');
A = image();
A
A =
Image with properties: CData: [64×64 double] CDataMapping: 'direct' Show all properties
Notice that A = image() was a call to the image() function and asked for a default image to be displayed and for the object handle to be assigned to A.

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

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

製品

リリース

R2009b

タグ

質問済み:

2021 年 3 月 16 日

コメント済み:

2021 年 3 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by