Solved

Saving a bmp file to IMA format

  • 30 July 2021
  • 1 reply
  • 192 views

Hello,

 

Is there a method or tool to save a .bmp file as a .IMA file?  I have a bitmap of a target reticle I created in Solidworks and I want to perform an extended diffraction analysis.  The extended diffraction analysis requires an IMA file.

 

Thanks,

 

Pat

icon

Best answer by David.Nguyen 2 August 2021, 10:53

View original

1 reply

Userlevel 7
Badge +2

Hi Pat,

 

I don’t have a tool ready for conversion, but I believe you could write a small Python script to do this job.

The format of *.IMA files is given in the Help File (F1) under

The Analyze Tab (sequential ui mode) > Image Quality Group > Extended Scene Analysis > Geometric Image Analysis 

and it reads

 

There are two different IMA file formats, one text and one binary. Whichever file format is used, the file must end in the extension IMA. OpticStudio will distinguish between the two types of file formats automatically.

The text image file is a text file which ends in the extension .IMA. At the top of the file is one number which indicates the size of the file in pixels. The remaining rows and columns contain the pixel data, with one character to each pixel. All IMA files must be square, with n x n pixels defined. For example, a 7 x 7 representation of the letter "F" could be described by the following IMA file:

7
0111110
0100000
0100000
0111100
0100000
0100000
0100000Note that the single entry "7" starts the file, and it is followed by a carriage return. Then there are 7 rows of 7 columns each, and each row is terminated with a carriage return. The columns are not separated by a space or any other character. The image file must be square. OpticStudio will attempt to allocate enough memory to hold the image file and will report an error if there is not enough memory.

The "intensity" at each pixel can be any digit between 0 and 9. The number of rays each pixel will generate is proportional to this value. Pixels with a value of 0 do not radiate any rays.

The binary IMA file format is more complicated than the text format, and binary IMA files cannot be edited with a text editor. However, the binary IMA files are dramatically more powerful. Each pixel in the binary IMA file is represented by an unsigned byte, which means there are 256 "gray-scale" levels of intensity. Furthermore, each wavelength can be assigned a separate pixel map. Therefore, very realistic photograph like extended sources can be modeled.

The binary IMA file format requires 3 16-bit header values. The first 16-bit value is a signed integer that must be equal to zero. The second 16-bit signed integer is the width of the pixel map in pixels, which can be any number from 1 to 8000. The third 16-bit signed integer is the number of pixel maps, which correspond to the number of colors (or wavelengths) represented in the file.

For example, a 3-color binary pixel map of a 50 by 50 image would have 6 bytes of header (0, 50, and 3), followed by 2500 bytes for color 1, then 2500 bytes for color 2, then 2500 bytes for color 3, for a total of 7506 bytes. The data for each color is stored by columns for each row (the column index changes faster than the row index).

 

Let me know if this helps.

Take care,

 

David

Reply