is it possible to adjust the codes such a way that it'l read all sizes of images
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
geethi
il 19 Mar 2013
Commentato: Md Fakhrul Alam Sajib
il 28 Feb 2018
is it possible to adjust the codes such a way that it'l read all sizes of images currently its taking only 11kb
function out=load_database();
% We load the database the first time we run the program.
persistent loaded;
persistent w;
if(isempty(loaded))
v=zeros(10304,400);
for i=1:40
cd(strcat('s',num2str(i)));
for j=1:10
a=imread(strcat(num2str(j),'.pgm'));
v(:,(i-1)*10+j)=reshape(a,size(a,1)*size(a,2),1);
end
cd ..
end
w=uint8(v); % Convert to unsigned 8 bit numbers to save memory.
end
loaded=1; % Set 'loaded' to aviod loading the database again.
out=w;
9 Commenti
Image Analyst
il 15 Apr 2013
Please start a new question so we don't keep bugging geethi with new emails for your question.
Walter Roberson
il 15 Apr 2013
The jpeg is probably RGB, a 3-dimensional array whose total size is size(a,1) * size(a,2) * size(a,3). You can recode as
v(:,(i)*6+j) = a(:);
Risposta accettata
Image Analyst
il 19 Mar 2013
You need to either make v a cell array, so that each element would be an image of a different size, or you need to call imresize before you stuff it into a column of v (if v is to remain just a regular numerical array).
2 Commenti
Image Analyst
il 20 Mar 2013
Looks like it thinks title() is one of your variables instead of the built-in function. Set a breakpoint at that line and say
k>> whos title
k>> which -all title
and tell us what it says. You probably redefined title() to be a variable.
Più risposte (1)
Md Fakhrul Alam Sajib
il 26 Feb 2018
How to make v a cell array in this code. I want to adjust this codes such a way that it will read all sizes of images. Could anyone explain?
function out=load_database();
% We load the database the first time we run the program.
persistent loaded;
persistent w;
if(isempty(loaded))
v=zeros(10304,400);
for i=1:40
cd(strcat('s',num2str(i)));
for j=1:10
a=imread(strcat(num2str(j),'.pgm'));
v(:,(i-1)*10+j)=reshape(a,size(a,1)*size(a,2),1);
end
cd ..
end
w=uint8(v); % Convert to unsigned 8 bit numbers to save memory.
end
loaded=1; % Set 'loaded' to aviod loading the database again.
out=w;
3 Commenti
Md Fakhrul Alam Sajib
il 27 Feb 2018
Thank you. Is it correct way to make v a cell array? I am still getting this error....
Error using reshape,
To RESHAPE the number of elements must not change.
Error in load_database (line 12)
v(:,(i-1)*10+j)=reshape(a,size(a,1)*size(a,2),1);
function out=load_database()
% We load the database the first time we run the program.
persistent loaded;
persistent w;
if(isempty(loaded))
v={zeros(10304,400)};
for i=1:40
cd(strcat('s',num2str(i)));
for j=1:10
a=imread(strcat(num2str(j),'.pgm'));
v(:,(i-1)*10+j)=reshape(a,size(a,1)*size(a,2),1);
end
cd ..
end
w=uint8(v); % Convert to unsigned 8 bit numbers to save memory.
end
loaded=1; % Set 'loaded' to aviod loading the database again.
out=w;
Vedere anche
Categorie
Scopri di più su Language Support in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!