ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Read TIF file as array

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
esprd Posted - Jul 24 2025 : 10:53:53
Hi,

I have TIF files generated by python program containing "integer values" (some are negative) for each "pixel" instead of real color value.
In fact, the data they contain are more "array of data" than picture.

Is there a way to get the values stored in the files with ImageEn ?

I've loaded the file in a TImageEnMView, but then I'm stuck to get the values.

Best regards

ep
6   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Jul 28 2025 : 23:35:37
Hi

So, ImageEn does not support this type of format so you would need to process the pixels using another method.

Alternatively if you could output your TIFF as:

BitsPerSample = 32
SamplesPerPixel = 1
SampleFormat = SampleFmt_IEEEFP
PhotometricInterpretation = Photomet_BlackIsZero_ID

Then ImageEn could load the image natively as ie32f.




Nigel
Xequte Software
www.imageen.com
esprd Posted - Jul 28 2025 : 01:53:35
Hi Nigel,

This code gives:

procedure TForm1.Button2Click(Sender: TObject);
var
  iePixelF : TIePixelFormat ;

begin
  if OpenImageEnDialog1.Execute then
  begin
    ImageEnView1.IO.Params.NativePixelFormat := true ;
    ImageEnView1.IO.LoadFromFile( 'OpenImageEnDialog1.FileName' ) ;
    iePixelF := ImageEnView1.IEBitmap.PixelFormat ;
  end;

end;


iePixelF = ie24RGB

Attached an example of file.

Regards

attach/esprd/202572815134_Example.TIF

ep
xequte Posted - Jul 27 2025 : 19:13:01
Yes, that is a good way if it is not a true TIFF format.

What PixelFomat does ImageEn use if you set NativePixelFormat to true before loading?

http://www.imageen.com/help/TIOParams.NativePixelFormat.html

Also, can you attach an example file?


Nigel
Xequte Software
www.imageen.com
atrust Posted - Jul 26 2025 : 19:31:20




Hi,
You can use ImageEnView to load the TIFF file and obtain its width and height. This tells you how many rows the image has, and how many integer values are in each row.
However, to read the actual integer values directly, I suggest using a separate file-reading method, like TMemoryStream, to load the TIFF file as raw bytes.
Then, locate the offset where stores the data block "tifffile.py". The actual 32-bit integer values start 16 bytes after that position (as indicated by the red arrow).
From there, you can read the data directly as an array of integers.
esprd Posted - Jul 25 2025 : 12:04:26
Hi,

Here is an example of the code generating the file :

//------------------------------------
import numpy as np
import tifffile

# Generate 2D array of shape (2000, 3000) with int32 type
# this example generates random values from -1500 to 1500
labels_table = np.random.randint(
    low=-1500,
    high=1500,
    size=(2000, 3000),
    dtype=np.int32,
)

# Write to TIFF file
tifffile.imwrite(
    "labels.tif",
    labels_table,
    dtype=np.int32,
    photometric="minisblack",
    metadata=None,
)

//------------------------------------

ep
atrust Posted - Jul 24 2025 : 22:37:48
Hi, could you please share the Python code that generates that kind of TIF file?