Switch to unified view

a b/functions/adjustFormatForPCANet.m
1
function [imagesCellTrain, imageSize] = adjustFormatForPCANet(imagesCellTrain, imageSize)
2
3
if nargin == 1
4
    %compute image size
5
    %image size must be a power of 2
6
    im = imagesCellTrain{1};
7
    closPow2 = pow2(floor(log2(size(im,1))));
8
    imageSize = [closPow2 closPow2];
9
end
10
11
for i = 1 : numel(imagesCellTrain)
12
    
13
    %load
14
    im = imagesCellTrain{i};
15
    
16
    im = im2double(im);
17
    
18
    if size(im, 3)
19
        im = rgb2gray(im);
20
    end %if size
21
    
22
    %image size must be a power of 2
23
    im = imresize(im, imageSize);
24
    
25
    %assign
26
    imagesCellTrain{i} = im;
27
    
28
end %for i = 1 : numel(imagesCellTrain)