Using MATLAB to save a montage of many images as one large image file at full resolution -


i trying save montage of many (~500, 2mb each) images using matlab function imwrite, keep getting error:

error using imwrite>validatesizes (line 632) images must contain fewer 2^32 - 1 bytes of data. error in imwrite (line 463) validatesizes(data); 

here code working with:

close clear clc tic file = 'imageregistrations.txt'; info = importdata(file); imagenames = info.textdata(:,1); xoffset = info.data(:,1); yoffset = info.data(:,2); = 1:length(imagenames); imagenames{i,1} = imread(imagenames{i,1}); imagenames{i,1} = flipud(imagenames{i,1}); end imagenames = flipud(imagenames);  i=1:length(imagenames)     diffx(i) = xoffset(length(imagenames),1) - xoffset(i,1); end diffx = (diffx)'; diffx = flipud(diffx);  j=1:length(imagenames)     diffy(j) = yoffset(length(imagenames),1) - yoffset(j,1); end diffy = (diffy)'; diffy = flipud(diffy); matrix = zeros(max(diffy)+abs(min(diffy))+(2*1004),max(diffx)+abs(min(diffx))+(2*1002)); %matrix(1:size(imagenames{1,1},1),1:size(imagenames{1,1},2)) = imagenames{1,1}; q=1:length(imagenames) matrix((diffy(q)+abs(min(diffy))+1):(diffy(q)+abs(min(diffy))+size(imagenames{q,1},1)),(diffx(q)+abs(min(diffx))+1):((diffx(q)+abs(min(diffx))+size(imagenames{q,1},2)))) = imagenames{q,1}; end  graymatrix = mat2gray(matrix); graymatrix = flipud(graymatrix); figure(2) imshow(graymatrix) imwrite(graymatrix, 'montage.tif') toc 

i use imwrite because perserves final montage in full resolution file, whereas if click save on figure file saves low resolution file.

thanks!

error says on tin, really. there sort of inbuilt limitation input variable size in imwrite, , you're going on it.

note images stored uint8 guess end doubles result of processing. increases memory usage.

it may be, therefore, casting type help. try using im2uint8 (presuming variable graymatrix double, scaled between 0 , 1), before calling imwrite.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -