% function resizeResearchImage(f_in, f_out) % % Read in an image from the file f_in, resize it to the dimensions needed % for the DRIV wiki Research page, and save the image in the file f_out. % If the image does not have the correct aspect ratio, it is padded with a % white border. % function resizeResearchImage(f_in, f_out) new_row = 200; new_col = 150; img = imread(f_in); [r, c] = size(img); aspect = r/c; if (aspect < new_row/new_col) resized = imresize(img, [NaN new_col]); else resized = imresize(img, [new_row NaN]); end padded = padImage(resized, [new_row new_col]); imwrite(padded, f_out); function padded = padImage(img, dims) [r, c, d] = size(img); rs = floor((dims(1) - r)/2) + 1; cs = floor((dims(2) - c)/2) + 1; padded = uint8(255*ones([dims d])); padded(rs:rs+r-1, cs:cs+c-1,:) = img;