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 Ansichten (letzte 30 Tage)

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 Kommentar
mohd akmal masud
mohd akmal masud am 30 Jun. 2023
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)

Melden Sie sich an, um zu kommentieren.

Antworten (1)

DGM
DGM am 23 Mär. 2023
Bearbeitet: DGM am 30 Jun. 2023
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)
ans = 3×2
384 2048 512 1536 768 1024
  3 Kommentare
DGM
DGM am 1 Jul. 2023
Bearbeitet: DGM am 1 Jul. 2023
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)

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Convert Image Type finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by