matlab - Create an array of rgb images in mat format? -


i having 60 images of size 250x250x3 . want add stack of images. ie, want create 4-d array, holds images in form of mat file. so, should of size 250 x 250 x 3 x 60 .

i have tried following. when displays image full of white small marks only. code .

x=zeros(250,250,3,60) i=1:60 x(:,:,:,i)=image1 , on on every every loop. 

any way create mat.

the problem:

it seems yout images stored uint8 type. when pre-allocated x defined double (by default).
when matlab displays image there difference between uint8 type image , double type image: uint8 matlab expects intensities range between [0..255]. however, when comes double type images matlab expects values range between [0..1]. thus, assigning uint8 image values double type have double type image values in range [0..255] - matlab displays white.

solutions:

there several ways can solve problem:

  • define x uint8 type

    x = zeros( [255, 255, 3, 60], 'uint8' ) save memory uint8 takes single byte whereas double takes 8.

  • alternatively, can cast images double using im2double function changes data type and range of intensities [0..1].


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -