All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > General > Cryptography
Noisy Code (Posted on 2005-01-15) Difficulty: 3 of 5

See The Solution Submitted by Sam    
Rating: 4.4167 (12 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Solution Using Only Paint | Comment 15 of 17 |

The problem with using paint, as already stated, is that it does not have an XOR filter. Putting two black-and-white images on top of each other with either color transparent is like an OR, and doing the color inversion is like a logical NOT. So, the problem becomes trying to reproduce an XOR with only a NOT (~) and an OR (|):

A B ~A ~B A|B ~A|~B ~(A|B) ~(~A|~B)
T T F F T F F T
T F F T T T F F
F T T F T T F F
F F T T F F T F
(~(A|B))|(~(~A|~B)) ~(~(A|B))|(~(~A|~B)) A XOR B
T F F
F T T
F T T
T F F

So, there you go. To use just ORs and NOTs to simulate an XOR gate, it's possible, but pretty complex. Letting the top half of the image be A and the bottom have be B, here's what it would look like:

<img src="https://i.imgur.com/1wKsSO0.png">

Of course, Paint is not quite that limited. Specifically, you can specify whether white or black is the background color, thus enabling you to OR the blacks or the whites without need for color inversion at every step. So the above is a nice theoretical/analytical approach, but now how you'd actually want to do it. Here's how to approach it in paint:

1. Divide the image into two halves as above. Make a second copy of either half (I did the bottom).
<img src="https://i.imgur.com/PLnUvfL.png">

2. Cut the one image and paste it on top of both copies of the other, once with white as the background color, and once with black as the background color.
<img src="https://i.imgur.com/l8uABFY.png">

3. Invert either of the two images you now have (I did the top one).
<img src="https://i.imgur.com/wM1fdca.png">

4. Move one on top of the other. Whether you use black or white for the transparent background color will depend on which image you inverted in the last step and whether that one originally was made with a black or white filter. Just try both; one will show words and the other will be a blank box (everything cancels out).
<img src="https://i.imgur.com/YoA98nl.png">

And that's it! The trick to doing it in paint is, you need to capture the differences from white to black and from black to white, and get rid of the pixels that are the same. Simply pasting one half on top of the other will find black to white or white to black, but not both. Both of the methods I've described above work, although the second is a bit simpler. You may notice that each has an odd number of inversions, and both result in white letters on black background. The original message was black text on a white background, and another inversion of the final product (so that each pixel is inverted an even number of times) will produce the original picture exactly.

Also, note that if you copy the image out of your web browser and paste directly into paint, all of the pixels will not be exactly black or white, which will cause some problems when trying to paste using a transparent background. I used a separate program to reduce the image to 2 colors before pasting into paint, or you can save it as a monochrome bitmap to get rid of the inconsistencies. The slight differences in color may also be due to the original image not being exactly black letters, as shown in the filtered image Jay produced. The Paint method as described will only work for images of exactly two colors.

Fun problem!

Edited on May 12, 2021, 8:13 am
  Posted by DJ on 2005-01-20 17:39:19

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (15)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information