Différences
Ci-dessous, les différences entre deux révisions de la page.
| Prochaine révision | Révision précédente | ||
| projets:dataimage_gaspard_mathy [2024/05/11 11:30] – créée etudiant_e | projets:dataimage_gaspard_mathy [2024/05/11 12:51] (Version actuelle) – [projet final] etudiant_e | ||
|---|---|---|---|
| Ligne 66: | Ligne 66: | ||
| Cette méthode me permet de réaliser les codes suivants | Cette méthode me permet de réaliser les codes suivants | ||
| - | V1: | + | //V1// |
| < | < | ||
| PImage img; | PImage img; | ||
| - | + | vd setup() { | |
| - | void setup() { | + | size(2000, 1328); |
| - | size(2000, | + | img = loadImage(" |
| - | img = loadImage(« ton | + | |
| img.resize(width, | img.resize(width, | ||
| } | } | ||
| Ligne 90: | Ligne 89: | ||
| float b = blue(c); | float b = blue(c); | ||
| - | | + | |
| - | // Modification pour la composante rouge dominante | + | |
| - | r += 0; | + | |
| - | g += -255; | + | r = map(différence, |
| - | b += -255; | + | g = map(différence, |
| - | } else if (g > r && | + | b = map(différence, |
| - | // Modification pour la composante verte dominante | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | // Modification pour la composante bleue dominante | + | |
| - | r += -255; | + | |
| - | g += -255; | + | |
| - | b += 0; | + | |
| - | } | + | |
| // Limiter les valeurs entre 0 et 255 | // Limiter les valeurs entre 0 et 255 | ||
| Ligne 120: | Ligne 109: | ||
| image(img, 0, 0); | image(img, 0, 0); | ||
| - | saveFrame(« ton | + | |
| - | | + | noLoop(); |
| } | } | ||
| </ | </ | ||
| + | //Detection des pixels ayant toute leurs valeurs RVB pair (ex 244,12,100) | ||
| + | Qui copie la couleur des pixels se trouvant a 5 pixels a leur droite tout en soustrayant 40 a chacune des valeurs rvb// | ||
| - | V2 | + | < |
| + | PImage img; | ||
| + | |||
| + | void setup() { | ||
| + | size(800, | ||
| + | img = loadImage(" | ||
| + | img.loadPixels(); | ||
| + | } | ||
| + | |||
| + | void draw() { | ||
| + | background(255); | ||
| + | |||
| + | int offset = 5; // Valeur de décalage, ajustez selon vos besoins | ||
| + | |||
| + | for (int y = 0; y < img.height; y++) { | ||
| + | for (int x = 0; x < img.width - offset; x++) { | ||
| + | // Récupérer la couleur du pixel à droite (avec décalage) | ||
| + | color rightPixelColor = img.pixels[(x + offset) + y * img.width]; | ||
| + | |||
| + | // Extraire les composantes de couleur (rouge, vert, bleu) | ||
| + | int redValue = int(red(rightPixelColor)); | ||
| + | int greenValue = int(green(rightPixelColor)); | ||
| + | int blueValue = int(blue(rightPixelColor)); | ||
| + | |||
| + | // Vérifier si toutes les composantes sont des nombres pairs | ||
| + | if (redValue % 2 == 0 && greenValue % 2 == 0 && blueValue % 2 == 0) { | ||
| + | // Diminuer les valeurs RVB de 40 | ||
| + | redValue = max(0, redValue - 40); | ||
| + | greenValue = max(0, greenValue - 40); | ||
| + | blueValue = max(0, blueValue - 40); | ||
| + | |||
| + | // Affecter la nouvelle couleur au pixel actuel | ||
| + | img.pixels[x + y * img.width] = color(redValue, | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | img.updatePixels(); | ||
| + | image(img, 0, 0); | ||
| + | |||
| + | // Enregistrer l' | ||
| + | saveFrame(" | ||
| + | |||
| + | // Arrêter le dessin après avoir appliqué la transformation | ||
| + | noLoop(); | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | //Detection roue quand tt les valeurs rvb sont pair = rue si nn blanc// | ||
| < | < | ||
| Ligne 133: | Ligne 171: | ||
| void setup() { | void setup() { | ||
| - | size(2000,1328); | + | size(1920, 1080); |
| - | img = loadImage(" | + | img = loadImage(" |
| - | img.resize(width, height); | + | img.loadPixels(); |
| } | } | ||
| void draw() { | void draw() { | ||
| - | | + | |
| - | | + | int offset |
| - | for (int j = 0; j < img.height; j++) { | + | |
| - | int index = i + j * img.width; | + | |
| - | color c = img.pixels[index]; | + | |
| - | float r = red(c); | + | for (int y = 0; y < img.height; y++) { |
| - | | + | for (int x = 0; x < img.width - offset; x++) { |
| - | | + | |
| + | | ||
| - | int différence | + | // Extraire les composantes de couleur (rouge, vert, bleu) |
| + | | ||
| + | int greenValue = int(green(rightPixelColor)); | ||
| + | int blueValue = int(blue(rightPixelColor)); | ||
| - | | + | // Vérifier si toutes les composantes sont des nombres pairs |
| - | | + | if (redValue % 2 == 0 && greenValue % 2 == 0 && |
| - | | + | // Affecter |
| - | g = 0; | + | |
| - | b = 0; | + | } else { |
| - | } else if (60 > différence | + | // Affecter |
| - | // Modification pour la composante verte dominante | + | |
| - | | + | |
| - | g = 127; | + | |
| - | b = 127; | + | |
| - | } else if ( 60 < différence ) { | + | |
| - | // Modification pour la composante bleue dominante | + | |
| - | | + | |
| - | g = 255; | + | |
| - | b = 255; | + | |
| } | } | ||
| + | } | ||
| + | } | ||
| - | // Limiter les valeurs entre 0 et 255 | + | img.updatePixels(); |
| - | r = constrain(r, 0, 255); | + | image(img, 0, 0); |
| - | g = constrain(g, 0, 255); | + | |
| - | b = constrain(b, 0, 255); | + | |
| - | | + | |
| - | img.pixels[index] = color(r, g, b); | + | saveFrame(" |
| + | |||
| + | // Arrêter le dessin après avoir appliqué la transformation | ||
| + | noLoop(); | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | //Les 4 couleurs noir rouge vert bleu en fonction du nombre de valeur rvb pair/ | ||
| + | |||
| + | < | ||
| + | PImage img; | ||
| + | |||
| + | void setup() { | ||
| + | size(600, 400); | ||
| + | img = loadImage(" | ||
| + | img.loadPixels(); | ||
| + | } | ||
| + | |||
| + | void draw() { | ||
| + | background(255); | ||
| + | |||
| + | int offset = 5; // Valeur de décalage, ajustez selon vos besoins | ||
| + | |||
| + | for (int y = 0; y < img.height; y++) { | ||
| + | for (int x = 0; x < img.width - offset; x++) { | ||
| + | // Récupérer la couleur | ||
| + | color rightPixelColor = img.pixels[(x + offset) + y * img.width]; | ||
| + | |||
| + | // Extraire | ||
| + | int redValue = int(red(rightPixelColor)); | ||
| + | int greenValue = int(green(rightPixelColor)); | ||
| + | int blueValue = int(blue(rightPixelColor)); | ||
| + | |||
| + | // Compter le nombre de composantes RVB impaires | ||
| + | | ||
| + | if (redValue % 2 != 0) oddCount++; | ||
| + | if (greenValue % 2 != 0) oddCount++; | ||
| + | if (blueValue % 2 != 0) oddCount++; | ||
| + | |||
| + | // Affecter la couleur appropriée au pixel actuel | ||
| + | if (oddCount == 2) { | ||
| + | // Deux valeurs RVB impaires, affecter la couleur verte | ||
| + | | ||
| + | } else if (redValue % 2 == 0 && greenValue % 2 == 0 && blueValue % 2 == 0) { | ||
| + | // Trois valeurs RVB paires, affecter la couleur rouge | ||
| + | img.pixels[x + y * img.width] = color(255, 0, 0); | ||
| + | } else if (redValue % 2 != 0 && greenValue % 2 != 0 && blueValue % 2 != 0) { | ||
| + | // Trois valeurs RVB impaires, affecter la couleur bleue | ||
| + | img.pixels[x + y * img.width] = color(0, 0, 255); | ||
| + | } | ||
| } | } | ||
| } | } | ||
| - | updatePixels(); | + | |
| image(img, 0, 0); | image(img, 0, 0); | ||
| - | | + | // Enregistrer l' |
| - | | + | |
| + | // Arrêter le dessin après avoir appliqué la transformation | ||
| + | noLoop(); | ||
| } | } | ||
| </ | </ | ||
| - | V3 | + | ces différents codes me permettent de modifier mes images en parcourant les valeurs rvb de chacun des pixels de celles-ci afin d'en modifier la valeur. voici quelque images test produites avec ceux-ci; |
| + | |||
| + | {{: | ||
| + | |||
| + | {{: | ||
| + | |||
| + | {{: | ||
| + | |||
| + | les résultats ne me plaisaient pas, je voulais sortir de l' | ||
| + | |||
| + | ====== projet final ====== | ||
| + | |||
| + | je me lance alors sur ma dernière idée je veux créer deux codes, l'un pour cacher une image bitmap dans une autre a travers les valeurs RVB de celle-ci et un second pour en extraire le contenu. | ||
| + | |||
| + | afin de réaliser des texts rapidement, je code ceci : | ||
| < | < | ||
| + | |||
| PImage img; | PImage img; | ||
| - | vd setup() { | + | void setup() { |
| - | size(2000, 1328); | + | size(4, 2); |
| - | img = loadImage("ton image.jpg" | + | img = createImage(width, |
| - | | + | img.loadPixels(); |
| + | |||
| + | int[] pixelsValues = { | ||
| + | color(255, 255, 255), | ||
| + | color(0, 0, 0), | ||
| + | color(140, 25, 25), | ||
| + | color(121, 25, 25), | ||
| + | color(255, 255, 255), | ||
| + | color(0, 0, 0), | ||
| + | color(140, 25, 25), | ||
| + | color(121, 25, 25) | ||
| + | }; | ||
| + | |||
| + | for (int i = 0; i < img.width * img.height; i++) { | ||
| + | img.pixels[i] = pixelsValues[i]; | ||
| + | } | ||
| + | |||
| + | img.updatePixels(); | ||
| + | image(img, 0, 0); | ||
| + | |||
| + | saveFrame("screen-0017.png" | ||
| + | |||
| + | } | ||
| + | |||
| + | </ | ||
| + | |||
| + | afin d' | ||
| + | |||
| + | {{: | ||
| + | |||
| + | avec cet outil et sur base de mes codes précédents, | ||
| + | |||
| + | // | ||
| + | |||
| + | < | ||
| + | |||
| + | PImage img1; | ||
| + | PImage img2; | ||
| + | |||
| + | void setup() { | ||
| + | size(1992, 1328); | ||
| + | |||
| + | img1 = loadImage(" | ||
| + | | ||
| + | |||
| + | img2 = loadImage(" | ||
| + | img2.resize(width, | ||
| + | |||
| + | loadPixels(); | ||
| } | } | ||
| void draw() { | void draw() { | ||
| - | | + | |
| + | for (int j = 0; j < img1.height; | ||
| + | int index1 = i + j * img1.width; | ||
| + | color c1 = img1.pixels[index1]; | ||
| + | float r1 = red(c1); | ||
| + | |||
| + | |||
| + | int x2 = i % img2.width; | ||
| + | int y2 = j % img2.height; | ||
| + | int index2 = x2 + y2 * img2.width; | ||
| + | color c2 = img2.pixels[index2]; | ||
| + | float r2 = red(c2); | ||
| + | |||
| + | float add = r1 + r2; | ||
| + | |||
| + | if (add % 2 != 0) { | ||
| + | |||
| + | if (r1 < 255) { | ||
| + | r1 = constrain(r1 + 1, 0, 255); | ||
| + | } else { | ||
| + | r1 = constrain(r1 - 1, 0, 255); | ||
| + | } | ||
| + | img1.pixels[index1] = color(r1, green(c1), blue(c1)); | ||
| + | } | ||
| + | } | ||
| + | } | ||
| - | | + | |
| - | | + | image(img1, 0, 0); |
| - | int index = i + j * img.width; | + | |
| - | color c = img.pixels[index]; | + | saveFrame(" |
| + | | ||
| + | } | ||
| - | float r = red(c); | + | </ |
| - | float g = green(c); | + | |
| - | float b = blue(c); | + | |
| - | int différence = (int)(max(r, | + | //photos de base// |
| - | // Ajuste les valeurs de r, g, et b en fonction de la valeur de différence | + | {{: |
| - | r = map(différence, | + | |
| - | g = map(différence, | + | |
| - | b = map(différence, | + | |
| - | // Limiter les valeurs entre 0 et 255 | + | {{: |
| - | r = constrain(r, | + | |
| - | g = constrain(g, | + | |
| - | b = constrain(b, | + | |
| - | | + | //photo modifiée contenant |
| - | | + | |
| + | {{: | ||
| + | |||
| + | // | ||
| + | |||
| + | < | ||
| + | |||
| + | PImage img1; | ||
| + | |||
| + | void setup() { | ||
| + | size(1992, | ||
| + | img1 = loadImage(" | ||
| + | img1.resize(width, | ||
| + | } | ||
| + | |||
| + | void draw() { | ||
| + | loadPixels(); | ||
| + | |||
| + | for (int i = 0; i < img1.width; i++) { | ||
| + | for (int j = 0; j < img1.height; | ||
| + | | ||
| + | color c1 = img1.pixels[index]; | ||
| + | |||
| + | float r1 = red(c1); | ||
| + | |||
| + | |||
| + | if (red(c1) % 2 != 0) { | ||
| + | |||
| + | c1 = color(255, 255, 255); | ||
| + | } else { | ||
| + | c1 = color(0, 0, 0); | ||
| + | } | ||
| + | |||
| + | |||
| + | img1.pixels[index] = c1; | ||
| } | } | ||
| } | } | ||
| updatePixels(); | updatePixels(); | ||
| - | image(img, 0, 0); | + | image(img1, 0, 0); |
| - | | + | saveFrame(" |
| noLoop(); | noLoop(); | ||
| } | } | ||
| + | |||
| </ | </ | ||
| + | |||
| + | //photo extraite// | ||
| + | |||
| + | {{: | ||
| + | |||
| + | //bug si les formats d' | ||
| + | |||
| + | {{: | ||
| + | |||
| + | ---- | ||
| + | |||
| + | ====== conclusion ====== | ||
| + | |||
| + | pour conclure, je suis content Des apprentissages que j'ai pu faire lors de ce cours, ce que j'ai pu y réaliser reste encre difficile a associer avec ma pratique photo courante mais cette ouverture du médium m'a permis d' | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||