5 ms·
There's no way for the computer to know which way is correct and which way is a mirror image.
by Houshalter 10y ago
There's no way for the computer to know which way is correct and which way is a mirror image.
- gnicholas 10y agoYes, but it comes out flipped 100% of the time. I ran the train image 10 times and it was backwards (you can tell from the numbers) every single time. This is more than just chance.
- oxguy3 10y agoThe algorithm isn't random -- every time you run your image through it, it's doing the same exact maths, and getting the same exact result. It's random whether or not any image you might pick will be flipped, but for a given image, the result will always be the same.
- vardump 10y agoWhether it is flipped or not seems to depend entirely on how it ended up being shuffled. Maybe that's why you don't use Javascript Math.Random() for cryptographic purposes? :-) Shuffle function: function doShuffle() { var startTime = Date.now(); var pixels = shuffledImage.data; while (shuffleStartColumn < width) { // Pick a random column j in the range [i, width) and move it to position i. // This Fisher-Yates shuffle is the less efficient than the Durstenfeld shuffle but more animatedly appealing. var i = shuffleStartColumn; var j = i + Math.floor(Math.random() * (width - i)); for (var y = 0; y < height; y++) { for (var x = j - 1; x >= i; x--) { var off = (y * width + x) * 4; for (var k = 0; k < 4; k++) { var temp = pixels[off + k]; pixels[off + k] = pixels[off + 4 + k]; pixels[off + 4 + k] = temp; } } } shuffleStartColumn++; if (Date.now() - startTime > YIELD_AFTER_TIME) break; }