Struct contents reference from a non-struct array object.

my code tochange an image to gray using rgb2gray, had been running well until one day it begun displaying this message: Struct contents reference from a non-struct array object. a very simple code as the one below still has the same problem... am totally confused someone help me.
clc;
img = imread('img.jpg');
imshow(img);
img_gray = rgb2gray(img);
imshow(img_gray);

回答 (1 件)

madhan ravi
madhan ravi 2018 年 12 月 25 日
編集済み: madhan ravi 2018 年 12 月 25 日

0 投票

clc;
img1 = imread('img.jpg'); % just try changing img variable to img1 not sure it would work but just a try
imshow(img1);
img_gray = rgb2gray(img1);
imshow(img_gray);
What does the below show ?
if it says it‘s a variable or you have a file with the same name as the any of the three below please rename it .
which imread -all
which imshow -all
which rgb2gray -all
whos img % just try clear all at the very beginning and try again

1 件のコメント

ENOC MOGEN
ENOC MOGEN 2018 年 12 月 26 日
Thanks for your prompt response
I came to realize that there was another code I had executed early in another folder and it somehow 'got stuck in memory' or something like that, because when I deleted the folder with that code, mine started working normal without having to change anything.
Thanks

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

質問済み:

2018 年 12 月 25 日

コメント済み:

2018 年 12 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by