is it possible to adjust the codes such a way that it'l read all sizes of images
4 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Image Analyst
2013 年 4 月 15 日
Please start a new question so we don't keep bugging geethi with new emails for your question.
Walter Roberson
2013 年 4 月 15 日
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(:);
採用された回答
Image Analyst
2013 年 3 月 19 日
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 件のコメント
Image Analyst
2013 年 3 月 20 日
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.
その他の回答 (1 件)
Md Fakhrul Alam Sajib
2018 年 2 月 26 日
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 件のコメント
Md Fakhrul Alam Sajib
2018 年 2 月 27 日
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;
参考
カテゴリ
Help Center および File Exchange で Language Support についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!