clear clc ext='.NEF'; file='DSC_000 ('; V1='V1_'; V2='V2_'; V3='V3_'; numimages=147; TIF='tif'; for i=147:numimages+147 name=num2str(i); % if i<10 % name=['00' name]; % elseif i<100 % name=['0' name]; % end name=[num2str(i) ')']; a=nefRead([file name ext]); [x y z]=size(a); im=round(mean(a,3)); if round(3*((i/(49*3))-floor(i/(49*3))))==1 fn=V1; elseif round(3*((i/(49*3))-floor(i/(49*3))))==2 fn=V2; else fn=V3; end num=num2str(ceil(i/(49*3)); im=im/max(max(im))*2^16; imwrite(uint16(im),[fn num '.' TIF],'tif'); end