AmplifiCat

It enhances the shadows and saturation of the original image.

Example result with the image with
Tabby Cat With Long Fur
http://www.photos-public-domain.com/2012/04/06/tabby-cat-with-long-fur/


It enhances the shadows and saturation of the original image.

Example result with the image with
Gray Tabby Cat On Kitchen Counter
http://www.photos-public-domain.com/2010/12/03/gray-tabby-cat-on-kitchen-counter/


Description of this image manipulation code.

Image manipulation type creative coding made with Processing.
It enhances the shadows and saturation of the original image.
This is a revised version of PsychedeliCat.

You can use your own photo. 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



Processing example code.

Please feel free to use it, if you like it.
To see other works based on my code is my pleasure. And my honor.


// AmplifiCat.
// @author @deconbatch
// @version 0.2
// Processing 3.2.1
// 0.1 2017.06.05
// 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.setStroke(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() {

    noFill();
    PShape psDp = createShape(RECT, -0.5, -0.5, 1, 1);
    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);
  smooth(8);
  noLoop();

  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() {

  background(0, 0, 0);
  translate((width - canvasW) / 2, (height - canvasH) / 2);

  for (int cntEffect = 0; cntEffect < 36 * rateSize; ++cntEffect) {
    slideAndDraw();
    slideBack();
  }

  drawPixels();

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

}

void slideAndDraw() {

  // ommit zero row and column
  for (int idxW = 2; idxW < img.width; ++idxW) {  
    for (int idxH = 2; idxH < img.height; ++idxH) {

      int idxFlatmate = idxH * img.width + idxW;
      int idxNeighbor = (idxH - 2) * img.width + (idxW - 2);
          
      color flatmate = img.pixels[idxFlatmate];
      color neighbor = img.pixels[idxNeighbor];

      if (abs(saturation(flatmate) - saturation(neighbor)) > 10  ||
          abs(brightness(flatmate) - brightness(neighbor)) > 14) {
        img.pixels[idxNeighbor] = color(
                                        hue(flatmate),
                                        saturation(flatmate) * 1.20,
                                        brightness(flatmate) * 0.99
                                        );
      } else {
        img.pixels[idxNeighbor] = color(
                                        hue(flatmate),
                                        saturation(flatmate) * 0.99,
                                        brightness(flatmate) * 1.05
                                        );
      }

    }
  }

}

void slideBack() {

  for (int idxW = img.width - 1; idxW >= 2; --idxW) {  
    for (int idxH = img.height - 1; idxH >= 2; --idxH) {

      int idxFlatmate = idxH * img.width + idxW;
      int idxNeighbor = (idxH - 2) * img.width + (idxW - 2);

      img.pixels[idxFlatmate] = img.pixels[idxNeighbor];

    }
  }

}

void drawPixels() {
  
  for (int idxW = 0; idxW < img.width; ++idxW) {  
    for (int idxH = 0; idxH < img.height; ++idxH) {
      color c = img.pixels[idxH * img.width + idxW];
      pushMatrix();
      translate(idxW, idxH);
      brush.setElementFill(hue(c), saturation(c), brightness(c), 100);
      brush.show();
      popMatrix();
    }
  }

}


/*
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 
*/





Yes, I know. I don't have to use 'abstract class PshapeElement ' at all...

No comments :

Post a Comment