"Johnson Lau" on  wrote...
| Dear all,
|
| I need to convert some black and white TIFF images into a matrix of 1s and 0s.
|
| For example, there is a black and white TIFF with 4x4 pixels (a square
| represents a pixel):
|
| http://www.comminn.net/ftp/4x4.JPG
|
| I would like to convert it into a plaintext matrix like this:
|
| 0011
| 1001
| 1101
| 1110
|
| Could imagemagick help? Or I need other software? Thanks for your help!
|
Yes, very much!!!  It is just a matter of finding the right image format
that is close to what you want!

Convert the image to a a PBM format but without the binary compression!
that is as a text bitmap

For example....
   convert bitmap_image.gif -compress None bitmap.pbm

and you get...
   P1
   4 4
   1 1 0 0 0 1 1 0 0 0 1 0 0 0 0 1

however the PbmPlus library binary to text converter, will format
it slightly better....

   convert bitmap_image.gif PBM:- | pnmnoraw > bitmap.pbm

and you get...
   P1
   4 4
   1100
   0110
   0010
   0001

Now just strip the first two lines and you have your bitmap text array



WARNING: JPEG is a lossy format and when reading you will get some grey
values.  It may be a good idea to do a -threshold 50%  in the "convert"
command to ensure it outputs a true bitmap.


  Anthony Thyssen ( System Programmer )    <[EMAIL PROTECTED]>
 -----------------------------------------------------------------------------
     Rose: "Stairs, thats more like it!  It hasn't got legs." ....
     Dalek: "Elevate!"                    -- Dr Who 2007, "Dalek"
 -----------------------------------------------------------------------------
     Anthony's Home is his Castle     http://www.cit.gu.edu.au/~anthony/
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users

Reply via email to