Unable to perform assignment because the size of the left side is 1024-by-1 and the size of the right side is 3072-by-1 , How to fix such an error in read_image_set script ?

조회 수: 1 (최근 30일)
function [X,T]=read_image_set() % ver 03/02/18
%
% Notation:
% Np=30 is the number of persons to be recognised by the given images.
% Each person is taken 50 times, k=50.
% The images are reshaped to be 32 by 32 pixels.
% The number of images N=Np*k=30*50=1500.
% Inputs:
% There are N jpg images representing the Np persons.
% Function:
% Each image is vectorised to be a vector including
% L=32*32=1024 elements.
% Ouputs:
% X is the (L by N) matrix of vectorised images of Np persons.
% T is the N-element target vector including the person indexes 1 to Np.
% Settings:
% dname is the folder name including all the N images.
% nofpix=30 is the size of images in pixels, It can be reasonably
% changed for improving the recognition accuracy.
%
dname='Image'; % the folder name
nofpix=32; % image size
nofvect=nofpix*nofpix;
path(dname,path);
Fn=dir(dname);
n=size(Fn,1);
N=n-2;
X=single(zeros(nofvect,N));
TA=single(zeros(1,N));
for i=3:n
fname=Fn(i).name;
Im=imread(fname,'ppm');
%figure(1)
%imshow(Im)
Im1=imresize(Im,[nofpix nofpix]);
%figure(2)
%imshow(Im1)
V=single(Im1(:));
i1=i-2;
X(:,i1)=V;
TA(i1)=str2double(fname(6:7));
end
T=call_order_labels(TA);
return
function T=call_order_labels(TA)
% record the labels TA without missing values
U=unique(TA);
n=length(U);
T=zeros(size(TA));
for i=1:n
I=TA==U(i);
T(I)=i;
end
return
I am using benchmark traffic sign images with 29x30 pixel; but when I run this read_image_set script I am getting this error:
Unable to perform assignment because the size of the left side is 1024-by-1 and the size of the right side is 3072-by-1.
Error in read_image_set (line 40) X(:,i1)=V;
Do you know how to fix it ? thank you.

답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by