The creative coding manipulates the photo into a flamboyant image.

A cat photo that was processed with Processing code.
Image manipulation example with 'Tortie Cat'.
http://www.photos-public-domain.com/2016/08/21/tortie-cat/

A cat photo that was processed with Processing code.
Image manipulation example 'Gray Tabby Cat on Kitchen Counter'.
http://www.photos-public-domain.com/2010/12/03/gray-tabby-cat-on-kitchen-counter/

 







Description of this creative coding image manipulation.

This is a creative coding image manipulation example made with the 'Processing'. It creates a flamboyant image. It's a derivation of my other image manipulation work 'Gleameow'.

I tried to emphasize the contours of cats. So I put a grayscale image first and put color ellipses with alpha(transparency) on it.

 

Grayscale image.

Grayscale image.

 

Only color ellipses.

Only color ellipses.

 

Color ellipses on grayscale image.

It worked!
Color ellipses on grayscale image.

 

Processing example code.

Please feel free to use this example code under the terms of the GPL. To see other works based on my code is my pleasure. And my honor.

 

You can use your own photo with this code.

You can hard coding the path of your photo image file or you can give command line parameter like this.

/your_processing_installed_path/processing-java --force --sketch=/your_sketch_path/ --run /your_photo_file_path

 

Example code.


// FlamboNyant.
// @author @deconbatch
// @version 0.2
// Processing 3.2.1
// 0.1 2017.10.08
// 0.2 2018.12.23

/* ---------------------------------------------------------------------- */
abstract class PshapeElement {

  PShape anElement;
  float elementColor, elementSaturation, elementBright, elementAlpha;
  
  PshapeElement() {
    anElement = pscreateElement();
    elementColor = 0;
    elementSaturation = 0;
    elementBright = 0;
    elementAlpha = 0;
  }

  abstract PShape pscreateElement();

  void setElementFill(float pcolor, float psaturation, float pbright, float palpha) {
    elementColor = pcolor;
    elementSaturation = psaturation;
    elementBright = pbright;
    elementAlpha = palpha;
    resetColor();
  }

  void resetColor() {
    anElement.setFill(color(elementColor, elementSaturation, elementBright, elementAlpha));
  }

  void changeColor(float scolor) {
    elementColor = scolor;
    resetColor();
  }

  void changeBright(float sbright) {
    elementBright = sbright;
    resetColor();
  }

  void resetSize() {
    anElement.resetMatrix();
  }

  void changeSize(float scaleX, float scaleY) {
    anElement.scale(scaleX, scaleY);
  }

  void rotate(float radX) {
    anElement.rotate(radX);
  }

  void show() {
    shape(anElement);
  }

}

/* ---------------------------------------------------------------------- */
class BoxBrush extends PshapeElement {

  
  BoxBrush() {
    super();
  }

  PShape pscreateElement() {

    PShape psDp = createShape(ELLIPSE, 0.0, 0.0, 1.0, 1.0);
    return psDp;

  }

}

/* ---------------------------------------------------------------------- */

PImage img;
PshapeElement brush;

float canvasW, canvasH;
float rateSize;

void setup() {
  size(1080, 1080);
  float baseWH = 980;
  
  colorMode(HSB, 360, 100, 100, 100);
  noStroke();
  smooth(8);
  noLoop();
  noiseSeed(0);

  brush = new BoxBrush();

  if (args == null) {
    // you can use your photo in ./data/your_image.jpg
    img = loadImage("your_image.jpg");
  } else {
    // args[0] must be image path
    img = loadImage(args[0]);
  }

  // fit to canvas size
  rateSize = baseWH / max(img.width, img.height);
  canvasW = img.width * rateSize;
  canvasH = img.height * rateSize;
  img.resize(int(canvasW), int(canvasH));
  img.loadPixels();

}

void draw() {

  float nzWStart = 0.0;
  float nzHStart = 19.0;
  float nzW = 0.0;
  float nzH = 0.0;

  blendMode(BLEND);
  background(0.0, 0.0, 90.0, 100.0);
  translate((width - canvasW) / 2, (height - canvasH) / 2);

  brush.resetSize();
  brush.changeSize(2.0, 2.0);

  nzW = nzWStart;
  for (int idxW = 0; idxW < img.width; ++idxW) {  

    nzH = nzHStart;
    for (int idxH = 0; idxH < img.height; ++idxH) {

      pushMatrix();
      translate(idxW, idxH);
      int idxPoint = idxH * img.width + idxW;
      color cPoint = img.pixels[idxPoint];
      float valHue = hue(cPoint);
      float valSat = saturation(cPoint) * map(noise(nzH, nzW), 0.0, 1.0, 0.0, 2.0);
      float valBri = brightness(cPoint) * map(noise(nzW, nzH), 0.0, 1.0, 0.0, 0.5);
      float valAlp = 100.0;
      brush.setElementFill(valHue, valSat, valBri, valAlp);
      brush.show();
      popMatrix();

      nzH += 0.004;

    }

    nzW += 0.002;

  }

  nzWStart = 6.0; //random(10.0);
  nzHStart = 0.0; //random(10.0);
  float divNoise = 0.012;

  blendMode(SCREEN);

  for (int dotSiz = 4; dotSiz <= 9; ++dotSiz) {
  
    nzW = nzWStart;
    for (int idxW = 0; idxW < img.width; idxW += dotSiz) {  

      nzH = nzHStart;
      for (int idxH = 0; idxH < img.height; idxH += dotSiz) {

        int idxPoint = idxH * img.width + idxW;
        color cPoint = img.pixels[idxPoint];

        float valSiz = 1.0 * dotSiz * dotSiz * dotSiz;
        float valHue = (hue(cPoint) + map(noise(nzW, nzH), 0.0, 1.0, -45.0, 45.0)) % 360.0;
        float valSat = map(saturation(cPoint), 0.0, 100.0, 400.0, 900.0) / dotSiz;
        float valBri = map(brightness(cPoint), 0.0, 100.0, 100.0 / 120.0, 100.0 / 30.0) * 1.0;
        float valAlp = map(brightness(cPoint) + saturation(cPoint), 0.0, 200.0, 1000.0, 100.0) / dotSiz / dotSiz;

        pushMatrix();
        translate(idxW, idxH);
        brush.resetSize();
        brush.changeSize(valSiz, valSiz);
        brush.setElementFill(valHue, valSat, valBri, valAlp);
        brush.show();
        popMatrix();

        nzH += divNoise;

      }

      nzW += divNoise;

    }
  }

  saveFrame("frames/####.png");
  exit();

}

/*
Copyright (C) 2017- deconbatch

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>
*/





Next Post Previous Post
No Comment
Add Comment
comment url