Page 1 of 1

merge binary files of same size

Posted: 2017-12-18T03:08:12-07:00
by odul
Hi everybody,

I have pairs of fairly large binary tiff-files of same dimensions which need to be merged together.

The file data may look like that:

file1:
0000000000000000000000
0111111100000000000000
0100000100000000000000
0100000100000000000000
0100000100000000000000
0100000100000000000000
0111111100000000000000
0000000000000000000000
0000000000000000000000


file2:
0000000000000000000000
0000000000000001000010
0000000000000000100100
0000000000000000011000
0000000000000000011000
0000000000000000100100
0000000000000001000010
0000000000000000000000
0000000000000000000000


desired result:
0000000000000000000000
0111111100000001000010
0100000100000000100100
0100000100000000011000
0100000100000000011000
0100000100000000100100
0111111100000001000010
0000000000000000000000
0000000000000000000000

Any idea, how can do that? I studied the documentation, but surrendered...

Re: merge binary files of same size

Posted: 2017-12-18T03:25:18-07:00
by snibgo
I suppose 0 represents black, and 1 represents white? Then the output at each pixel should be the lighter of the inputs:

Code: Select all

magick in1.tiff in2.tiff -compose Lighten -composite out.tiff

Re: merge binary files of same size

Posted: 2017-12-18T03:44:08-07:00
by odul
Hello snibgo,

thanks for your instant help. Unfortunately, I only get a totally white tiff as result:-(

BTW: typical file size ist 20000 times 35000 Pixels.

Re: merge binary files of same size

Posted: 2017-12-18T05:32:48-07:00
by snibgo
I thought that each 0 or 1 was a pixel, but perhaps not. Please tell us what they represent.

Also tell us what version of IM you are using, on what platform.

Re: merge binary files of same size

Posted: 2017-12-18T14:47:09-07:00
by odul
Thanks again for your help so far. I am using

ImageMagick 6.7.6-3 2012-04-28 Q16

in a cygwin Environment running on WIN 7. My files are one color, one bit per pixel. I do not know for sure, whether "1" means full Color or "no Color". I guessed "1" means full Color and so I created the example files.

I hope, that helps:-)

Re: merge binary files of same size

Posted: 2017-12-18T15:02:33-07:00
by snibgo
I think it wold help if you supplied links to example inputs files. Please make them small (eg no larger than 1000x1000).

Re: merge binary files of same size

Posted: 2017-12-18T16:29:20-07:00
by fmw42
Binary does not support color. Binary is black and white only with 1 bit per pixel. So we do not know what you mean by color images with 1-bit per pixel. As snibgo suggested perhaps supplying your input files might help. Or explain the file format in more detail.

Perhaps you mean the images are binary as opposed to text format. But what is the bit depth per pixel per channel? Is it 8-bits per pixel per channel (as 24-bit color image)? What is the endian -- are the higher bits on the left or right of the 8bits.