Menu

Parsing data from image byte stream

2013-05-19
2013-05-19
  • Eman Hassan

    Eman Hassan - 2013-05-19

    Hi all,
    I guess this discussion is open to the topic of how we can get data from image file without the need to apply any image processing techniques. More precisely, carefully examining the file format of the image and get measurement info directly from it.

    We can assume that the validity of this topic to Tiff image file format. We can extend it later to another file formats, but i believe we will not need to for many reasons.

    Here are findings about these image files sent to us :

    a) The header file is as follows :
    254 (0xfe: NewSubfileType): 0 (1 Long)
    256 (0x100: ImageWidth): 645 (1 Short)
    257 (0x101: ImageLength): 516 (1 Short)
    258 (0x102: BitsPerSample): 8 (1 Short)
    259 (0x103: Compression): 1 (1 Short)
    262 (0x106: PhotometricInterpretation): 1 (1 Short)
    271 (0x10f: Make): 'SIS, D-48153 Muenster' (22 ASCII)
    315 (0x13b: Artist): '' (1 ASCII)
    273 (0x111: PreviewImageStart): 32 (1 Long)
    279 (0x117: PreviewImageLength): 332820 (1 Long)
    277 (0x115: SamplesPerPixel): 1 (1 Short)
    278 (0x116: RowsPerStrip): 516 (1 Short)
    282 (0x11a: XResolution): 200 (1 Rational)
    283 (0x11b: YResolution): 200 (1 Rational)
    296 (0x128: ResolutionUnit): 1 (1 Short)
    305 (0x131: Software): 'analySIS 3.2' (13 ASCII)
    33560 (0x8318: Unknown Tag): 340893 (1 Long)
    Notes :
    --image pixel values in the file are not compressed (Compression=1), u can see the direct values if u open the file in hex editor after an offset of 32 byte.
    --There is a custom Tag (33560 (0x8318: Unknown Tag): 340893 (1 Long) ) which means that the physical measurements are stored explicitly by the software( which is very evident when the file is opened by notepad++), and can be parsed by a program.

    b) The Tiff file sees the data as only one image, which is the combination of scan image and a measurement bar. The Tiff file format can afford to have multiple images at the same file, and each image is represented by image file directory(IFD) segment. These file each contains only one segment and the data is packed up as a single strip of length = ImageWidth * ImageLength

    So to separate the scanned image from that of the measurement, we need to apply a simple image processing step. As this can not be extracted from the Tiff image file.

    My current problem :

    I want to use the value in the custom tag to programatically extract the measurement form the image bytes. This is how i am thing : the same way the header file is parsed : there is a field called "offsetToFirstIFD" which describes where to find the IFD segment(usually at the end of the tiff file), then that segment format is defined according to the tiff standard and it is parsed accordingly.
    The value of custom tag 340893 points directly before the IFD segment, but not to the start of "PhilipsTIFFHeader" which contains the actual measurements values. I believe there is a pre-defined way of how the custom tag point to some place in the file, this place can show how to parse the needed measurement. (the same way the header data is parsed) Can any one help me how to fine this definition, or i have to do some reverse engineering to get it ?

    thanks

     
  • Mohammed

    Mohammed - 2013-05-19

    Hello Eman,

    I cannot really grasp what you are trying to say. Are you trying to find out the scale measurement from the TIFF header or are you trying to extract some other measurements from the file header?

     
    • Eman Hassan

      Eman Hassan - 2013-05-19

      is there a standard format for the added measured parameters ?

       
  • Mohammed

    Mohammed - 2013-05-19

    I have no idea. I will check if the software has one. I think it would be better to try to get the pattern of the data from the current headers and match them to the value seen in the image.

     

Log in to post a comment.

Auth0 Logo