Can any body be kindly solve this error why occurs..Undefined function 'eq' for input arguments of type 'cell'.
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
aditya kumar sahu
am 6 Nov. 2016
Kommentiert: aditya kumar sahu
am 6 Nov. 2016
a=imread('f.jpg');
b=imresize(a,[16 16]);
c=dec2bin(b,8);
d=cellstr(dec2bin(b,8))';
ro=size(d,1);
co=size(d,2);
for i=1:ro
for j=1:co
p(i,j)=d(i,j);
end
end
for i=1:ro
for j=1:co
if d(i,j)==00000001 | 10000000
p(i,j)=00000001;
else
p(i,j)=10000000;
end
end
end
Undefined function 'eq' for input arguments of type 'cell'.
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 6 Nov. 2016
There is so much wrong with this beyond that. I've fixed a bunch of things and leave it to you to fix the rest (like d and p being 1-D or 2-D cell arrays):
grayImage = imread('peppers.png');
% Get the dimensions of the image.
% numberOfColorBands should be = 1 for a gray scale image, and 3 for an RGB color image.
[rows, columns, numberOfColorChannels] = size(grayImage);
if numberOfColorChannels > 1
% It's not really gray scale like we expected - it's color.
% Use weighted sum of ALL channels to create a gray scale image.
grayImage = rgb2gray(grayImage);
% ALTERNATE METHOD: Convert it to gray scale by taking only the green channel,
% which in a typical snapshot will be the least noisy channel.
% grayImage = grayImage(:, :, 2); % Take green channel.
end
% Resize the image
smallImage = imresize(grayImage,[16 16]);
c = dec2bin(smallImage,8);
d = cellstr(dec2bin(smallImage,8))';
[rows, columns, numberOfColorChannels] = size(d)
p = d; % Copy the cell array into p
for i = 1 : rows
for j = 1 : columns
if strcmp(d{i, j}, '00000001') || strcmp(d{i, j}, '10000000')
p{i,j} = '00000001';
else
p{i,j} = '10000000';
end
end
end
msgbox('Done!');
Weitere Antworten (1)
Alon Rozen
am 6 Nov. 2016
Hi Aditya,
I think it is because you set 'd' to be a cell and later you used it as if it is a matrix.
Try instead d(i,j) to use d{i,u}.
Alon
Siehe auch
Kategorien
Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!