Yin and Yang
Yin and Yang
Greetings from Darmstadt? Who from?
That was a nice challenge - what did you try first? I approached a bitwise (or should I say pixelwise in this case) OR which worked immediately. However the solution was not very readable in white. Did a XOR combination maybe lead to success too?
@osterlaus: Hm, now I'm curious. What are you studying?
@osterlaus: Hm, now I'm curious. What are you studying?
Don't ask me why, but this was my first approach. I took red as the result color and this worked even immediatelier as your white as I directly saw the solution.theStack wrote:That was a nice challenge - what did you try first? I approached a bitwise (or should I say pixelwise in this case) OR which worked immediately. However the solution was not very readable in white. Did a XOR combination maybe lead to success too?
Just guesstheStack wrote:@osterlaus: Hm, now I'm curious. What are you studying?
-
- Posts: 44
- Joined: Mon Feb 16, 2009 4:11 pm
- Location: UK
Well, that was almost too easy for such an advanced challenge. My first thought was to take the difference of the two images (in Photoshop for example) and that worked perfectly fine.
By the way, greetings from the Leibniz Universität Hannover, Germany. Good to hear that my uni is not the only one with a faible for umlauts in their international name...
By the way, greetings from the Leibniz Universität Hannover, Germany. Good to hear that my uni is not the only one with a faible for umlauts in their international name...
-
- Posts: 4
- Joined: Sat Mar 07, 2009 3:36 pm
- Location: Germany
-
- Posts: 44
- Joined: Mon Feb 16, 2009 4:11 pm
- Location: UK
-
- Posts: 273
- Joined: Thu Apr 10, 2008 9:47 pm
I put the two images on top of each other in two layers in Photoshop, and used a difference blending on the layers. I've seen a challenge like this many years ago but it involved 9 or so images of different colors, and blending them yielded a treasure map to which you were supposed to use to get through a maze.
I agree that this challenge seems fairly trivial. My first thought was to load the images on top of each other in Photoshop and to play around a bit with the layer modes – total time: 10 seconds.
But, on the other hand, there are not so many people in the solver list, and I am stuck on problems which must seem trivial to other people, so…
But, on the other hand, there are not so many people in the solver list, and I am stuck on problems which must seem trivial to other people, so…
-
- Posts: 17
- Joined: Thu Apr 21, 2011 3:08 am
-
- Forum Admin
- Posts: 496
- Joined: Sat May 28, 2011 9:14 am
- Location: Germany
It does not really matter whether you use AND, OR or XOR here. Possibly XOR gives the best result for reading.
Code: Select all
import javax.imageio.*;
import java.io.*;
import java.awt.image.BufferedImage;
public class Yin_Yang_Solver {
public static void main (String args[]) {
try {
BufferedImage image1 = ImageIO.read(new File("masgo-1.gif"));
BufferedImage image2 = ImageIO.read(new File("masgo-2.gif"));
BufferedImage image3 = new BufferedImage(400, 400, BufferedImage.TYPE_INT_RGB);
for(int i = 0; i < image1.getHeight(); i++) {
for(int j = 0; j < image1.getWidth(); j++) {
int color = image1.getRGB(j,i) ^ image2.getRGB(j,i); // or use &, or use |
image3.setRGB(j, i, color);
}
}
ImageIO.write(image3, "gif", new File("result.gif"));
}
catch(java.io.IOException e) {
System.out.println("File error: " + e);
}
}
}
-
- Posts: 33
- Joined: Sat Aug 13, 2011 2:13 pm