[Insight-users] re: MatLab viewing of ITK images
Karthik Krishnan
Karthik.Krishnan at kitware.com
Tue Feb 21 11:59:24 EST 2006
You can save them as raw images (with a mhd header)
The following function will load them up in matlab and display the
middle axial slice , saggital slice and coronal slice.
function DisplayImage(imgSize, fname,bit_depth,endian )
% function DisplayImage(imgSize,fname,bit_depth,endian)
% bitdepth can be 'int8', 'uint8', 'int16', 'uint16' or
% any of the other supported types
% Endianness can be 'ieee-be' or 'ieee-le'
%--------------------------------------------------------------
fid=fopen(fname,'rb',endian);
[img,count]=fread(fid,img_size,bit_depth);
img_r = reshape(img, imgSize);
fclose(fid);
subplot(131);imagesc(squeeze(D(:,:,round(end/2))));axis image;
colormap gray
subplot(132);imagesc(squeeze(D(:,round(end/2),:)));colormap gray
subplot(133);imagesc(squeeze(D(round(end/2),:,:)));colormap gray
For instance:
DisplayImage( [256 256 50], 'c:\Data\foo.raw', 'int16', 'ieee-le' )
HTH
-karthik
mrcheung at mdanderson.org wrote:
>Hi,
>
>Can anyone tell me how to view ITK CT and MRI images in MatLab ?
>
>Thx, Rex
>
>
>_______________________________________________
>Insight-users mailing list
>Insight-users at itk.org
>http://www.itk.org/mailman/listinfo/insight-users
>
>
>
More information about the Insight-users
mailing list