i am trying to read a image file of format result.int that is integer image file not able to open with imread function
3 ビュー (過去 30 日間)
古いコメントを表示
a=imread("result3.int")
Error using imread>get_format_info
Unable to determine the file format.
Error in imread (line 395)
fmt_s = get_format_info(fullname);
1 件のコメント
mohd akmal masud
2023 年 6 月 30 日
can try it
fid = fopen('jaszak1.int', 'r', 'ieee-le'); %jaszak1.int is your file name
data = fread(fid, inf, '*uint16');
fclose(fid);
data = reshape(data,64,64);
imagesc(data)
回答 (1 件)
DGM
2023 年 3 月 23 日
編集済み: DGM
2023 年 6 月 30 日
I'm going to assume that's an SGI black/white image. Since you didn't provide an example, I have no way of knowing that it's not something else.
imread() does not support any of the SGI image formats. You may be able to convert the image to a supported format (e.g. PNG) using GIMP, ImageMagick convert() or some other software.
Alternatively, you might be able to use this toolbox to read the file. It works for uncompressed and RLE compressed SGI files. It even appears to work for aggressive nonstandard RLE compression, though it dumps a bunch of warnings.
EDIT:
As @mohd akmal masud points out in the comments, a INT file may be a number of other things. In this thread, the INT file is a headerless uncompressed binary file.
It should be fairly easy to tell the difference, even if you don't know where the file originated. The first two bytes of a SGI INT file would be 0x01DA, and would be followed by the remaining header info as described here. The jaszak1.int file attached in the linked thread simply has no header. Nowhere in the file is there any information which specifies the data formatting (e.g. bytes per pixel element) or image geometry, though I suspect that it's possibly included in a separate header file.
Assuming that no header file or other insight is available, how can it be decoded? I simply looked at the file in a hex editor. It's fairly apparent that the data is formatted in two-byte elements, so I presumed that it's uint16. Since there are 4096 two-byte elements, I presumed that the geometry is simply 64x64.
What if your image has 786432 elements instead? How can you know the geometry? You can't really know, but you can make good guesses. Look at the factor pairs of the number and look for pairs which have an aspect ratio close to 1. While 4096 is a perfect square, 786432 is not. The factor pairs closest to unity are 1024x768 and 768x1024. Try them and see which one works. Depending on the intended element ordering, you might need to transpose the result.
Attached is MIMT factor2(), which makes this checking a lot simpler.
% get unique factor pairs with at least some specified aspect ratio
factor2(786432,'ordered',false,'minar',0.1)
3 件のコメント
DGM
2023 年 7 月 1 日
編集済み: DGM
2023 年 7 月 1 日
I'm not sure of the formatting, but this is my guess. I would assume that these images should have some sort of header files with them or at least some contextual information that would describe their format. All the information I can find about BIM binary images indicates that they do have a simple header (8 bytes of geometry info), which this file does not have.
EDIT. I'm dumb. It seems all the nonzero data appears to be in 4-byte words. I didn't think to check that it wasn't float.
fid = fopen('result1.bim', 'r', 'ieee-le');
data = fread(fid, inf, '*float');
fclose(fid);
data = reshape(data,128,128);
imagesc(data)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1423613/image.png)
参考
カテゴリ
Help Center および File Exchange で Convert Image Type についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!