Thread: Bitunwise

  1. #16
    Registered User Azmeos's Avatar
    Join Date
    Jun 2003
    Posts
    65
    Oh right. I fixed that ... it's a " " instead of a "". But I still am getting the wrong answer... every line is outputting the same thing. It's also outputting more than 20 (the image's width) pixel values.
    \0

  2. #17
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    if I had more time I would read the tiff specs and help you out. I can pretty much guarantee that the bit reading code is correct, I can not guarantee that what you're reading is right because I don't know the format and dont' have the time. It seems to be well documented though.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  3. #18
    Registered User Azmeos's Avatar
    Join Date
    Jun 2003
    Posts
    65
    The problem is, I've read through the documentation and it doesn't really help out in how to display the bitwise images, unfortunately. I've read from http://libtiff.org . Do you have a better site/documentation for programming with the TIFF library?
    \0

  4. #19
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    I would look at Wotsit.org as hk_mp5kpdw suggested. At first glance, tiff doesn't really look that horrible. but it is just a quick glance. The library you're working with though may not be so well documented.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  5. #20
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Maybe this will help. Here is a hex dump of your file.
    Code:
    49 49 2A 00 8A 00 00 00 58 02 00 00 01 00 00 00 58 02 00 00 
    01 00 00 00 38 00 00 00 4B 00 00 00 67 00 00 00 80 00 00 00 
    13 00 00 00 1C 00 00 00 19 00 00 00 09 00 00 00 80 3F DF EF 
    08 14 12 07 05 84 40 DE 43 F7 83 82 19 01 00 80 38 47 4D 07 
    00 CD E0 E8 5B BC 1C 8B D8 20 FD E0 E0 13 1C 1C 10 E7 00 DD 
    E1 01 00 80 3A 07 EF 07 04 0E 0A F0 71 41 85 2D 07 FB 8D 60 
    EF 5F 9C 1F EF F7 84 04 80 3F DF EF 08 13 C2 02 00 00 0D 00 
    FE 00 04 00 01 00 00 00 00 00 00 00 00 01 03 00 01 00 00 00 
    14 00 00 00 01 01 03 00 01 00 00 00 1A 00 00 00 02 01 03 00 
    01 00 00 00 01 00 00 00 03 01 03 00 01 00 00 00 05 00 00 00 
    06 01 03 00 01 00 00 00 01 00 00 00 11 01 04 00 04 00 00 00 
    18 00 00 00 15 01 03 00 01 00 00 00 01 00 00 00 16 01 04 00 
    01 00 00 00 08 00 00 00 17 01 04 00 04 00 00 00 28 00 00 00 
    1A 01 05 00 01 00 00 00 08 00 00 00 1B 01 05 00 01 00 00 00 
    10 00 00 00 28 01 03 00 01 00 00 00 02 00 00 00 00 00 00 00

  6. #21
    Registered User Azmeos's Avatar
    Join Date
    Jun 2003
    Posts
    65
    So does that mean my file ISN'T just black and white bitonal?
    \0

  7. #22
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Well if each byte (8 bits) represents a pixel (0 for black, and 255 for white), then no.

    But if each bit represents a pixel, then it could still be.

    Or a third possibility is the data is compressed.

    The tif's file size is 300 bytes. I opened the tif and it is black and white (600x600). So a pixel must be one bit.

    You said the tif's width is 20. When I opened it, it was 600.

    Your program may be outputting the correct data. The tif's is just bigger than you thought. Somewhere in the tif header it may tell the width and height of the image.

  8. #23
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    from what I can tell:
    - the blue is a signature
    - green is offset to first "Image File Directory" (from spec)
    - the red is the width and height
    edit: red is resolution apparently
    Code:
    49 49 2A 00 8A 00 00 00 58 02 00 00 01 00 00 00 58 02 00 00 
    01 00 00 00 38 00 00 00 4B 00 00 00 67 00 00 00 80 00 00 00 
    13 00 00 00 1C 00 00 00 19 00 00 00 09 00 00 00 80 3F DF EF 
    08 14 12 07 05 84 40 DE 43 F7 83 82 19 01 00 80 38 47 4D 07 
    00 CD E0 E8 5B BC 1C 8B D8 20 FD E0 E0 13 1C 1C 10 E7 00 DD 
    E1 01 00 80 3A 07 EF 07 04 0E 0A F0 71 41 85 2D 07 FB 8D 60 
    EF 5F 9C 1F EF F7 84 04 80 3F DF EF 08 13 C2 02 00 00 0D 00 
    FE 00 04 00 01 00 00 00 00 00 00 00 00 01 03 00 01 00 00 00 
    14 00 00 00 01 01 03 00 01 00 00 00 1A 00 00 00 02 01 03 00 
    01 00 00 00 01 00 00 00 03 01 03 00 01 00 00 00 05 00 00 00 
    06 01 03 00 01 00 00 00 01 00 00 00 11 01 04 00 04 00 00 00 
    18 00 00 00 15 01 03 00 01 00 00 00 01 00 00 00 16 01 04 00 
    01 00 00 00 08 00 00 00 17 01 04 00 04 00 00 00 28 00 00 00 
    1A 01 05 00 01 00 00 00 08 00 00 00 1B 01 05 00 01 00 00 00 
    10 00 00 00 28 01 03 00 01 00 00 00 02 00 00 00 00 00 00 00
    Last edited by FillYourBrain; 07-10-2003 at 08:32 AM.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  9. #24
    Registered User Azmeos's Avatar
    Join Date
    Jun 2003
    Posts
    65
    The resolution tag says it's 600x600, but the image width/height is 20x26. Or does it appear differently for you?
    \0

  10. #25
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    Azmeos, I was only working off of what swoopy said. You're right. 20x26 can be found here in red:
    Code:
    49 49 2A 00 8A 00 00 00 58 02 00 00 01 00 00 00 58 02 00 00
    01 00 00 00 38 00 00 00 4B 00 00 00 67 00 00 00 80 00 00 00 
    13 00 00 00 1C 00 00 00 19 00 00 00 09 00 00 00 80 3F DF EF 
    08 14 12 07 05 84 40 DE 43 F7 83 82 19 01 00 80 38 47 4D 07 
    00 CD E0 E8 5B BC 1C 8B D8 20 FD E0 E0 13 1C 1C 10 E7 00 DD 
    E1 01 00 80 3A 07 EF 07 04 0E 0A F0 71 41 85 2D 07 FB 8D 60 
    EF 5F 9C 1F EF F7 84 04 80 3F DF EF 08 13 C2 02 00 00 0D 00 
    FE 00 04 00 01 00 00 00 00 00 00 00 00 01 03 00 01 00 00 00 
    14 00 00 00 01 01 03 00 01 00 00 00 1A 00 00 00 02 01 03 00 
    01 00 00 00 01 00 00 00 03 01 03 00 01 00 00 00 05 00 00 00 
    06 01 03 00 01 00 00 00 01 00 00 00 11 01 04 00 04 00 00 00 
    18 00 00 00 15 01 03 00 01 00 00 00 01 00 00 00 16 01 04 00 
    01 00 00 00 08 00 00 00 17 01 04 00 04 00 00 00 28 00 00 00 
    1A 01 05 00 01 00 00 00 08 00 00 00 1B 01 05 00 01 00 00 00 
    10 00 00 00 28 01 03 00 01 00 00 00 02 00 00 00 00 00 00 00
    But like I said, I don't know the format.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  11. #26
    Registered User Azmeos's Avatar
    Join Date
    Jun 2003
    Posts
    65
    I'm now trying a method of taking the whole Byte value and ANDing it with a binary mask. So far, I've been unsuccessful though.
    \0

  12. #27
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    I'm seeing what looks like an LZW type compression. I'll show the compressed section in green. 0100 at the end of each section is a usual ending marker in LZ compression I'll show that in blue. There is also an interesting offset table that I'll show in red
    Code:
    49 49 2A 00 8A 00 00 00 58 02 00 00 01 00 00 00 58 02 00 00
    01 00 00 00 38 00 00 00 4B 00 00 00 67 00 00 00 80 00 00 00 
    13 00 00 00 1C 00 00 00 19 00 00 00 09 00 00 00 80 3F DF EF 
    08 14 12 07 05 84 40 DE 43 F7 83 82 19 01 00 80 38 47 4D 07 
    00 CD E0 E8 5B BC 1C 8B D8 20 FD E0 E0 13 1C 1C 10 E7 00 DD 
    E1 01 00 80 3A 07 EF 07 04 0E 0A F0 71 41 85 2D 07 FB 8D 60 
    EF 5F 9C 1F EF F7 84 04 80 3F DF EF 08 13 C2 02 00 00 0D 00 
    FE 00 04 00 01 00 00 00 00 00 00 00 00 01 03 00 01 00 00 00 
    14 00 00 00 01 01 03 00 01 00 00 00 1A 00 00 00 02 01 03 00 
    01 00 00 00 01 00 00 00 03 01 03 00 01 00 00 00 05 00 00 00 
    06 01 03 00 01 00 00 00 01 00 00 00 11 01 04 00 04 00 00 00 
    18 00 00 00 15 01 03 00 01 00 00 00 01 00 00 00 16 01 04 00 
    01 00 00 00 08 00 00 00 17 01 04 00 04 00 00 00 28 00 00 00 
    1A 01 05 00 01 00 00 00 08 00 00 00 1B 01 05 00 01 00 00 00 
    10 00 00 00 28 01 03 00 01 00 00 00 02 00 00 00 00 00 00 00
    now the table of offsets seems to point to the start of each compressed section. look up LZW compression and I believe you'll have this figured out.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  13. #28
    Registered User Azmeos's Avatar
    Join Date
    Jun 2003
    Posts
    65
    Hmm... then can anyone find a small, uncompressed, bitonal TIFF image I could try?
    \0

  14. #29
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    You're right. It is 20x26. My fault. I was looking under resolution, not size.

Popular pages Recent additions subscribe to a feed