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

조회 수: 1 (최근 30일)
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'.

채택된 답변

Image Analyst
Image Analyst 2016년 11월 6일
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!');

추가 답변 (1개)

Alon Rozen
Alon Rozen 2016년 11월 6일
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

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by