Last active
October 3, 2018 17:58
-
-
Save andrusenn/1c3e8449bbd1719ed3c6427fdfa45423 to your computer and use it in GitHub Desktop.
Algoritmo base convolución
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Little pleasures of the Mona / Pequeños placeres de la mona | |
Andrés Senn | |
andressenn.com/pequenos-placeres-de-la-mona/ | |
Base algorithm | |
2018 | |
Lic: CC 4.0 International | |
#Processing | |
*/ | |
PImage mona_img = loadImage("mona.jpg"); | |
PImage kandinsky_img = loadImage("kandinsky.jpg"); | |
// Dos imagenes mismo tamaño / Two images same size | |
int offset_noise_x = 2000; | |
int offset_noise_y = 20000; | |
for (int x = 0; x < mona_img.width; x++) { | |
for (int y = 0; y < mona_img.height; y++) { | |
float noise = noise((x-offset_noise_x)*0.001, (y-offset_noise_y)*0.002); | |
int index = x + y * mona_img.width; | |
// Valores de la imagen kandinsky / Kandinsky image values | |
int xx = int(map(brightness(kandinsky_img.pixels[index] >> 16 & 0xFF), 0, 255, 0, m)); | |
int yy = int(map(brightness(kandinsky_img.pixels[index] >> 8 & 0xFF), 0, 255, 0, m)); | |
// Nueva posicion de los pixeles / New pixels position | |
int newx = int(x+xx*(cos(TWO_PI * noise*2))); | |
int newy = int(y+yy*(sin(TWO_PI * noise*2))); | |
// Nuevo indice / New index | |
int index2 = newx + newy * mona_img.width; | |
index2 = int(abs(index2 % mona_img.pixels.length)); | |
// Set pixels | |
set(x, y, mona_img.pixels[index2]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment