Iterate over all the pixels of the two images at once. Hence, we have to multiply all occurrences of u and v in the above expression by 255 (so the bitwise operations work), and divide by 255 at the very end to get back in the range that ImageMagick expects. The one problem here is that when ImageMagick does fx it normalises all the pixels in u and v in the range instead of as we expect, and doing bitwise on non-integers screws stuff up. Hence, the ImageMagick command would be: convert img1.png img2.img -fx "((255-u)&v)|(u&(255-v))" image_xor.png So to get NOT u we can just do 255-u, assuming image u is 8-bit. To get the NOT (there is a logical NOT but no bitwise NOT), we remember that NOT x = 255-x if x is 8-bit. ![]() To reconstruct bitwise XOR, we need convert img1 img2 -fx "(u & NOT v) | (NOT u & v)" img_out Now, -fx only has bitwise AND & and bitwise OR | in the way of bitwise operators. In the expression above, u and v stand for the first and second input images respectively. ![]() fx "xxx" basically says "perform the operation xxx on the image". It's a bit ugly (I'm sure someone with more ImageMagick-fu than me could clean it up but it works like this: ( img1, img2, img_out are the two input and single output file names respectively). ImageMagick can do it, although it's a bit convoluted.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |