From: Muhammad Razali on

Hi im working on signature verification..i have a set of 100 images in .bmp format..im doing the pre-processing step where i need to read,resize and store the images in same size and element before i can do pattern classification..need urgently..plz any help would be appreciated...tq
From: Walter Roberson on
Muhammad Razali wrote:
>
> Hi im working on signature verification..i have a set of 100 images in
> .bmp format..im doing the pre-processing step where i need to
> read,resize and store the images in same size and element before i can
> do pattern classification..need urgently

Okay, so which part are you stuck on?
Do you know how to read images?
How to resize them?
How to store the resized images?
What formats are possible for the images? Are they grayscale, indexed
images, or true-color images?
What format do the images need to be in so that you can use the pattern
classification on them?
From: Muhammad Razali on
Walter Roberson <roberson(a)hushmail.com> wrote in message <FwXHn.8094$HG1.244(a)newsfe21.iad>...
> Muhammad Razali wrote:
> >
> > Hi im working on signature verification..i have a set of 100 images in
> > .bmp format..im doing the pre-processing step where i need to
> > read,resize and store the images in same size and element before i can
> > do pattern classification..need urgently
>
> Okay, so which part are you stuck on?
> Do you know how to read images?
> How to resize them?
> How to store the resized images?
> What formats are possible for the images? Are they grayscale, indexed
> images, or true-color images?
> What format do the images need to be in so that you can use the pattern
> classification on them?

Dear Walter,

the images are logical and in bitmap lformat.. i know how to read and resize for single image but stuck on set of images. Here is the code

disp('++++++++++++++++++ Signature ++++++++++++++++++++');
%database image
clear all;
close all;
count = 0;
ext = '.bmp';
%load list.txt
%[names, types, x, y, answer] = textread('list.txt', '%s %s %f %d %s', 6)
[tr_data, tr_class, x, y, answer] = textread('train_file.txt', '%s %d %f %d %s'); %train
%[ts_data, ts_class, x, y, answer] = textread('list_ts_face.txt', '%s %d %f %d %s'); %test
[ts_data, ts_class, x, y, answer] = textread('test_file.txt', '%s %d %f %d %s'); %test

limit_size = 20; %20x5%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


[mtr ntr] = size(tr_data); %mtr
[mts nts] = size(ts_data); %mts
mtr;
mts;

row = 112;
col = 92;


save limit_size limit_size;
save mtr mtr;
save mts mts;
save tr_class tr_class;
save ts_class ts_class;


%prepare train data space
tr_im = tr_data(1);
tr_com = strcat(tr_im, ext);
im1 = imread(char(tr_com));
[m n]=size(im1); %m = row, n = col
tr_space = logical(zeros(m*n, mtr));

%read train image 2D-1D
for i = 1:1:mtr
tr_im = tr_data(i);
class_tr(i) = tr_class(i);
tr_com = strcat(tr_im, ext);
tmp_tr= imread(char(tr_com));
tr_space(:,i) = reshape(tmp_tr', m*n, 1);
end
??? Error using ==> reshape
To RESHAPE the number of elements must not change.

This is the part where i got stuck

After doing some reading i think that its not working because each of the size of the 100images is different resulting it cannot read the whole set of the images.The code works well before when i use pgm format set of images which are in the same size..My plan is to resize and store the whole set of images but got stuck..any suggestion plz help
From: Walter Roberson on
Muhammad Razali wrote:

> the images are logical and in bitmap lformat.. i know how to read and
> resize for single image but stuck on set of images. Here is the code

> disp('++++++++++++++++++ Signature ++++++++++++++++++++');
> %database image
> clear all;
> close all;
> count = 0;
> ext = '.bmp';
> %load list.txt
> %[names, types, x, y, answer] = textread('list.txt', '%s %s %f %d %s', 6)
> [tr_data, tr_class, x, y, answer] = textread('train_file.txt', '%s %d %f
> %d %s'); %train
> %[ts_data, ts_class, x, y, answer] = textread('list_ts_face.txt', '%s %d
> %f %d %s'); %test
> [ts_data, ts_class, x, y, answer] = textread('test_file.txt', '%s %d %f
> %d %s'); %test
>
> limit_size = 20; %20x5%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
>
> [mtr ntr] = size(tr_data); %mtr
> [mts nts] = size(ts_data); %mts
> mtr;
> mts;
>
> row = 112;
> col = 92;
>
>
> save limit_size limit_size;
> save mtr mtr;
> save mts mts;
> save tr_class tr_class;
> save ts_class ts_class;
>
>
> %prepare train data space
> tr_im = tr_data(1);
> tr_com = strcat(tr_im, ext);
> im1 = imread(char(tr_com));
> [m n]=size(im1); %m = row, n = col
> tr_space = logical(zeros(m*n, mtr));
>
> %read train image 2D-1D
> for i = 1:1:mtr
> tr_im = tr_data(i);
> class_tr(i) = tr_class(i);
> tr_com = strcat(tr_im, ext);
> tmp_tr= imread(char(tr_com)); tr_space(:,i) = reshape(tmp_tr',
> m*n, 1);
> end
> ??? Error using ==> reshape
> To RESHAPE the number of elements must not change.
>
> This is the part where i got stuck

tr_space(:,i) = reshape(tmp_tr .', [], 1);

would be easier there.

> After doing some reading i think that its not working because each of
> the size of the 100images is different resulting it cannot read the
> whole set of the images.The code works well before when i use pgm format
> set of images which are in the same size..My plan is to resize and store
> the whole set of images but got stuck..any suggestion plz help


tr_space(:,i) = reshape( imresize(tmp_tr .', m, n), [], 1);

Or possibly the m and n would have to be reversed.
From: Muhammad Razali on
Walter Roberson <roberson(a)hushmail.com> wrote in message <yL%Hn.14298$rE4.6637(a)newsfe15.iad>...
> Muhammad Razali wrote:
>
> > the images are logical and in bitmap lformat.. i know how to read and
> > resize for single image but stuck on set of images. Here is the code
>
> > disp('++++++++++++++++++ Signature ++++++++++++++++++++');
> > %database image
> > clear all;
> > close all;
> > count = 0;
> > ext = '.bmp';
> > %load list.txt
> > %[names, types, x, y, answer] = textread('list.txt', '%s %s %f %d %s', 6)
> > [tr_data, tr_class, x, y, answer] = textread('train_file.txt', '%s %d %f
> > %d %s'); %train
> > %[ts_data, ts_class, x, y, answer] = textread('list_ts_face.txt', '%s %d
> > %f %d %s'); %test
> > [ts_data, ts_class, x, y, answer] = textread('test_file.txt', '%s %d %f
> > %d %s'); %test
> >
> > limit_size = 20; %20x5%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> >
> >
> > [mtr ntr] = size(tr_data); %mtr
> > [mts nts] = size(ts_data); %mts
> > mtr;
> > mts;
> >
> > row = 112;
> > col = 92;
> >
> >
> > save limit_size limit_size;
> > save mtr mtr;
> > save mts mts;
> > save tr_class tr_class;
> > save ts_class ts_class;
> >
> >
> > %prepare train data space
> > tr_im = tr_data(1);
> > tr_com = strcat(tr_im, ext);
> > im1 = imread(char(tr_com));
> > [m n]=size(im1); %m = row, n = col
> > tr_space = logical(zeros(m*n, mtr));
> >
> > %read train image 2D-1D
> > for i = 1:1:mtr
> > tr_im = tr_data(i);
> > class_tr(i) = tr_class(i);
> > tr_com = strcat(tr_im, ext);
> > tmp_tr= imread(char(tr_com)); tr_space(:,i) = reshape(tmp_tr',
> > m*n, 1);
> > end
> > ??? Error using ==> reshape
> > To RESHAPE the number of elements must not change.
> >
> > This is the part where i got stuck
>
> tr_space(:,i) = reshape(tmp_tr .', [], 1);
>
> would be easier there.
>
> > After doing some reading i think that its not working because each of
> > the size of the 100images is different resulting it cannot read the
> > whole set of the images.The code works well before when i use pgm format
> > set of images which are in the same size..My plan is to resize and store
> > the whole set of images but got stuck..any suggestion plz help
>
>
> tr_space(:,i) = reshape( imresize(tmp_tr .', m, n), [], 1);
>
> Or possibly the m and n would have to be reversed.


Dear walter

Thanks for the help but this is what happened when i try to use the statement .

tr_space(:,i) = reshape(tmp_tr .', [], 1);

??? Subscripted assignment dimension mismatch.

tr_space(:,i) = reshape( imresize(tmp_tr .', m, n), [], 1);

??? Error using ==> imresize>parsePreMethodArgs at 379
Invalid input syntax; input argument # 3 is unrecognized

Error in ==> imresize>parseInputs at 259
[params.A, params.map, params.scale, params.output_size] = ...

Error in ==> imresize at 136
params = parseInputs(varargin{:});

the same error come out when i try to reversed the m and n. Here is the full program i write, maybe it can explain more..

disp('++++++++++++++++++ Signature ++++++++++++++++++++');
%database image
clear all;
close all;
count = 0;
ext = '.bmp';
%load list.txt
%[names, types, x, y, answer] = textread('list.txt', '%s %s %f %d %s', 6)
[tr_data, tr_class, x, y, answer] = textread('train_file.txt', '%s %d %f %d %s'); %train
%[ts_data, ts_class, x, y, answer] = textread('list_ts_face.txt', '%s %d %f %d %s'); %test
[ts_data, ts_class, x, y, answer] = textread('test_file.txt', '%s %d %f %d %s'); %test

limit_size = 20; %20x5%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


[mtr ntr] = size(tr_data); %mtr
[mts nts] = size(ts_data); %mts
mtr;
mts;

row = 112;
col = 92;


save limit_size limit_size;
save mtr mtr;
save mts mts;
save tr_class tr_class;
save ts_class ts_class;


%prepare train data space
tr_im = tr_data(1);
tr_com = strcat(tr_im, ext);
im1 = imread(char(tr_com));
[m n]=size(im1); %m = row, n = col
tr_space = logical(zeros(m*n, mtr));

%read train image 2D-1D
for i = 1:1:mtr
tr_im = tr_data(i);
class_tr(i) = tr_class(i);
tr_com = strcat(tr_im, ext);
tmp_tr= imread(char(tr_com));
tr_space(:,i) = reshape(tmp_tr, m*n, 1);
end

train_sign_space = tr_space;
tr_mean = mean(double(tr_space'))'; %calculate mean
sign_mean = tr_mean;

save train_sign_space train_sign_space; %%%%%%%%%%%%%%%%%%%%%%%%%

save class_tr class_tr;
save sign_mean sign_mean;

%prepare test data space
ts_im = ts_data(1);
ts_com = strcat(ts_im, ext);
im1 = imread(char(ts_com));
[m n]=size(im1); %m = row, n = col
ts_space = logical(zeros(m*n, mts));

%read test image 2D-1D
for i = 1:1:mts
ts_im = ts_data(i);
ts_com = strcat(ts_im, ext);
tmp_ts= imread(char(ts_com));
ts_space(:,i) = reshape(tmp_ts, m*n, 1);

end
test_face_space = ts_space;
save test_face_space test_face_space; %%%%%%%%%%%%%%%%%%%%%%%%%