Read img medical image without header in matlab

喜夏-厌秋 提交于 2019-12-19 05:04:58

问题


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 ?


回答1:


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);



回答2:


%%% 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);  


来源:https://stackoverflow.com/questions/23141204/read-img-medical-image-without-header-in-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!