Question

I have a radiograph .img file without the header file. However, the researchers who have published the file have given this information about it

High resolution (2048 x 2048 matrix size, 0.175mm pixel size)
Wide density range (12bit, 4096 gray scale)
Universal image format (no header, big-endian raw data)

Using this information, I tried fread command in Matlab to read the image into Matlab.

fid = fopen('image.img','r','B');
oneSlice = fread(fid, [2048 2048], '*uint8','B');
imshow(oneSlice)

However the resulting image is coming up as incorrect. Is there something that I am doing wrong ? Could someone suggest any different method to read this image file ?

Was it helpful?

Solution

The lung x-rays of the JSRT database (www.jsrt.or.jp/jsrt-db/eng.php), have that format. I tested this code with them and it works:

fid = fopen('image.img','r','b');
oneSlice = fread(fid, [2048 2048], '*uint16','b');
img = mat2gray(oneSlice, [0,4096]);
fclose(fid);

OTHER TIPS

%%% Read image
    fid = fopen('image.img','r','b');
    oneSlice = fread(fid, [2048 2048], '*uint16','b');
    img = mat2gray(oneSlice, [0,4096]);
    fclose(fid);

%%%rotate image

    imgR = imrotate(img,270);

%%%horizontal flip image

    imgRF = flipdim(TestImgR ,2);  
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top