Thursday, 15 August 2013

matlab - Resizing and saving images on a new directory -



matlab - Resizing and saving images on a new directory -

i writing simple function reads sequence of images, re-sizes them , saves each set of re-sized images new folder. here code:

function [ image ] = frameresize(folder, imgtype) frames = dir([folder '/' imgtype]); numframes = size(frames,1); new_size = 2; = 1 : numframes, image = double(imread([folder '/' frames(i).name])); j = 2 : 10, new_size = power(new_size, j); % creating new folder called 'low-resolution' on % previous directory mkdir ('.. low-resolution'); image = imresize(image, [new_size new_size]); imwrite(image, 'low-resolution'); end end end

i have 2 doubts:

how can save images specific names, im_1_64, im_2_64, etc. according iteration , resolution? how can create name of folder beingness created alter each iteration save images same resolution on same folder?

since know resolution be: new_size x new_size, can utilize in imwrite function:

imwrite(image, ['im_' num2str(i) '_' num2str(new_size) '.' imgtype]);

assuming imgtype holds extension.

to setup folders can this:

mkdir(num2str(new_size)) cd(num2str(new_size)) imwrite(image, ['im_' num2str(i) '_' num2str(new_size) '.' imgtype]); cd ..

image matlab image-processing

No comments:

Post a Comment