|
IMWRITE doesn't support writing int16 data. If you have R2009b or more recent, you may use the Tiff class instead.
"Nic Roberts" wrote in message <jm9d5t$hel$1@newscl01ah.mathworks.com>...
> Hi,
> I'm using 'imwrite' to create a new greyscale (int16) TIFF file but when I read the file back in all the image has been binaried (sp?) that is the greyscale values are either 0 or 255 also the int16 values I thought I had written have been converted to uint8.
>
> I'm sure I'm missing something obvious here.
>
> The code:
>
> clear;
> for k=1:445 %stack length 445
> num=k-1;
> % Generate input file name
> str_num_in=num2str(num);
> prefix='Image_00';
> if (num<10)
> pad=strcat(prefix,'00');
> elseif (num>9)&&(num<100)
> pad=strcat(prefix,'0');
> elseif (num>99)
> pad=strcat(prefix,'');
> end
> name_in=strcat(pad,str_num_in,'.DCM;1');
>
> % Read in file crop and threshold
> I=dicomread(name_in);
> Thres_I=zeros(1024,1024);
> for i=1:1024
> for j=1:1024
> if (I(i,j)>2500)&&(sqrt((i-512)^2+(j-512)^2)<500)
> Thres_I(i,j)=I(i,j);
> end
> end
> end
>
> % Generate output file name and write file
> str_num_out=num2str(num+1);
> name_out=strcat('Thres_',str_num_out,'.tif');
> imwrite(Thres_I,name_out,'TIFF');
> end
|