matlab - how to translate and scale the image? -
my image looks this:
the given imrgb = 320*512*3 double; color_map = 64*3 double; after using
[x, map] = rgb2ind(imrgb, color_map);
i x = 320*512 uint8. image big further processing. question how translate , scale image standard size of 32*32 pixels without losing important information ( mean non-black part of image important information)?
here 1 solution make each brain tile 32x32
image. comments explain code. basic idea is...
using block proc
to split large image 5x8 grid, because has 5 rows of brains , 8 columns of brains. call each of these images tile
resize each tile 32x32
using mat2cell
- split new small tiles individual images , display them
here code
im = rgb2gray(imrgb); max_rows = 32; max_cols = 32; %i assume every picture has 40 brains, 5 rows , 8 columns rows_brains = 5; cols_brains = 8; [m n] = size(im); %define resize function take 'block_struct' image , resize %it max_rows x max_cols fun = @(block_struct) imresize(block_struct.data,[max_rows max_cols]); %blockproc split image tiles. each tile should hold 1 brain %image. resize tile 32x32 tile using resize function %we defined earlier i2 = blockproc(im,[m/rows_brains n/cols_brains],fun); %split image small tiles individual pictures %each cell of indiv_brains contain 32x32 image of 1 brain indiv_brains = mat2cell(i2,max_rows*ones(1,rows_brains),max_cols*ones(1,cols_brains)); %displays brains figure(1); ii=1:1:rows_brains jj=1:1:cols_brains subplot(rows_brains, cols_brains, (ii-1)*cols_brains + jj); imshow(indiv_brains{ii,jj}); end end
and result, each of these individual images 32x32
Comments
Post a Comment