MATLAB Answers

Can any body be kindly solve this error why occurs..Undefined function 'eq' for input arguments of type 'cell'.

1 view (last 30 days)
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 Comments

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 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!');

Community Treasure Hunt

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

Start Hunting!