# (bit)Wise Images [closed]

Given a truth table and two images, use the truth table as a bitwise operation to the two images.

For example with the truth table:

  1 0
1 0 0
0 1 0


(Note that the top is the first image and the left is the second)

and the two images (0, 2, 4) (a 1x1 image, with the numbers being RGB values) and (30, 20, 10):

You would apply the above truth table to the numbers 0 and 30, of which's binary representations are 00000 and 11110. Using the truth table as a bitwise operation would get us 00000, or in decimal form 0.

This means that the red value of the first pixel would be 0.

Continuing this with the other RGB values would get us 2 and 4 for green and blue respectively.

So the output for this would be a 1x1 image with the only pixel having an RGB value of 0, 2, 4.

For images greater than 1x1, you apply the truth table for both corresponding pixels on both images and output it to the output image.

For example, if we had a pixel which is located at (x, y) in the image, you would apply the truth table to the R, G, and B values for the (x, y) position in the first image and the (x, y) position in the second. Once you have done this, the (x, y) position in the output image is the output of the truth table applied to the R, G, and B values.

NOTES:

You can use any default input or output method.

You can assume that the two input images are the same dimensions.

You can use any Standard Image I/O that supports RGB.

The truth table can be in any format you want.

As always, since this is code golf, lowest byte-count wins!

## closed as unclear what you're asking by Embodiment of Ignorance, mbomb007, xnor, Jo King, StephenMar 4 at 1:29

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• Could you explain how an example bigger than 1x1 would work? – xnor Mar 3 at 16:19
• Does "any image format" include a raw 2D array of RGB tuples? e.g. [[[12,34,26],[227,162,201]],[[54,231,43],[1,2,3]]] as a 2x2 "image"? – Kamil Drakari Mar 3 at 17:54
• ...and does it include a raw 2D array of RGB bytes? i.e. [[[[0,0,0,0,1,1,0,0],[0,0,1,0,0,0,1,0],[0,0,0,1,1,0,1,0]],...],...] being Kamil's [[[12,34,26],...],...]. – Jonathan Allan Mar 3 at 18:41
• @Kamil Yes, any image format, whether it is made up or not as long as it satifies our cirteria – MilkyWay90 Mar 4 at 0:41
• I downvoted this question because it is trivial in its current form (see Adám's answer). I'm guessing it was closed as unclear for the same reason. – lirtosiast Mar 4 at 5:02

# APL (Dyalog Unicode), 3 bytesSBCS

Full program. Prompts for first image, then truth table, then second image, all from STDIN. Images must be given as bit arrays (for example, 8 × height × width × 3, but this doesn't actually matter). The truth table must be given as a Boolean APL function. And yes, those are three identical boxes:

⎕⎕⎕


Try it online!

⎕ prompt for the first image

⎕ prompt for the function, and apply it with the following left argument:

⎕ prompt for the second image

• Ah, I thought the characters just weren't rendering for me – Jo King Mar 3 at 23:45
• @JoKing APL renders right on almost all systems. – Adám Mar 4 at 0:12
• If only my browser displayed this characters correctly – MilkyWay90 Mar 4 at 0:45
• @MilkyWay90 As Adam said, the characters are rendering correctly; it's just that they are all the same box character – Jo King Mar 5 at 1:40
• @JoKing oh okay. I couldn't see the previous comments (maybe they were deleted) – MilkyWay90 Mar 5 at 2:20