How to open 2D image as file attached.

1 Ansicht (letzte 30 Tage)
mohd akmal masud
mohd akmal masud am 22 Jun. 2023
Kommentiert: DGM am 2 Jul. 2023
Dear all,
I have the file as attached, the format is .int
Actually this is 2D planar image.
Anyone can help me to open it in Matlab?
  1 Kommentar
DGM
DGM am 23 Jun. 2023
This does not appear to be an SGI .INT file. In fact, it doesn't appear to have any header. What is it, where did it come from, and did it come with a header file?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

DGM
DGM am 23 Jun. 2023
Bearbeitet: DGM am 23 Jun. 2023
Nevermind. That was simpler than I thought.
fid = fopen('jaszak1.int', 'r', 'ieee-le');
data = fread(fid, inf, '*uint16');
fclose(fid);
data = reshape(data,64,64);
imagesc(data)
  2 Kommentare
mohd akmal masud
mohd akmal masud am 2 Jul. 2023
Bearbeitet: mohd akmal masud am 2 Jul. 2023
this is correct @DGM,
But what I confused is, why the matrix become 64x64, because the original matrix setting is 128x128?
Can you explain?
DGM
DGM am 2 Jul. 2023
I don't know anything about where this image came from or what it used to be. All I know is that you have 8192 bytes of data. Assuming there is no compression, that would either make a 64x64 image at 16b/pixel or a nonsquare 128x64 or 64x128 image at 8b/pixel. In order to arrange the file into 128x128, it would need to be 4b/pixel, which would be unlikely.
We could try using 4b/pixel:
... but it doesn't work out.
When I look at the file, I see a gradual transition from a zero field to some larger values. The way each nonzero byte is separated by a zero byte suggests that it's a 2-byte encoding. Reading the file at 8 or 4 bits per pixel will always produce an image with periodic gaps between nonzero pixels
So if the image used to be 128x128, I don't know how it got to be in this form. All I can do is look at what I see.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by