MATLAB: Format of a .raw file

raw files

I'm using these raw files which have a format of 8 entries in a row (each 4-bit hex). I want to display this data-set in matlab, however, these are 3D images, and hence, are not supported by load( ), imread( ), commands. Please help.

Best Answer

I see no evidence that those files are arranged 8 entries in a row, each 4-bit hex. Those files are binary files.
Download the walnut data set and unzip it. Then
fid = fopen('walnut.raw','r');
wal = reshape( fread(fid,inf,'*uint16'), 400, 296, 352);
%16 bit values are hard to display properly, so let us scale to floating point
swal = double(wal) . /max(wal(:));
imagesc( swal(:,:,100).') %show slice 100
colormap(gray(256))
The datasets are not all 16 bit unsigned values. The last one listed on the page is 8 bit, for which you would use *uint8 instead of *uint16 . One of them is listed as 16 bit but without indicating whether that is unsigned; try that one with *uint16 but you might need to work with in in *int16 (signed integer) which could affect how you need to scale it for display.