Feel my aura, human.
Example result with the image from
Orange And White Cat Closeup
http://www.photos-public-domain.com/2011/01/07/orange-and-white-cat-closeup/
Example result with the image from
Gray Tabby Cat With Flowers
http://www.photos-public-domain.com/2010/09/03/gray-tabby-cat-with-flowers/
Feel the cat's aura!
This image manipulation code was made with Processing.This is revised version of HairiCat.
I featured flowing lines and high saturation in this code. You can see mystique cats aura!
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
The 'Processing' example codes.
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.
Example code version 0.3.
/**
* Mewstique.
* It draws cat's aura.
*
* Processing 3.5.3
* @author @deconbatch
* @version 0.2
* created 0.1 2017.06.21
* updated 0.2 2018.12.23 : add background image drawing.
* updated 0.3 2020.02.23 : throw PshapeElement away.
*/
import java.util.Arrays;
PImage img;
float canvasW, canvasH;
void setup() {
size(980, 980);
float baseWH = 880;
colorMode(HSB, 360, 100, 100, 100);
blendMode(SCREEN);
strokeWeight(0.0001);
smooth(8);
noLoop();
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
float 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.0, 90.0, 0.0);
translate((width - canvasW) / 2, (height - canvasH) / 2);
// Draw background
noStroke();
blendMode(BLEND);
float maxBrightness = 10.0;
float maxSaturation = 100.0;
for (int idxW = 0; idxW < img.width; ++idxW) {
for (int idxH = 0; idxH < img.height; ++idxH) {
int idxPoint = idxH * img.width + idxW;
color cPoint = img.pixels[idxPoint];
float valSiz = 1.0;
float valRotate = map(random(1.0), 0.0, 1.0, -90.0, 90.0);
float valHue = hue(cPoint);
float valSat = map(saturation(cPoint), 0.0, 30.0, 0.0, maxSaturation);
float valBri = map(brightness(cPoint), 0.0, 100.0, 0.0, maxBrightness);
float valAlp = 100.0;
pushMatrix();
translate(idxW, idxH);
fill(valHue, valSat, valBri, valAlp);
rect(0.0, 0.0, valSiz, valSiz);
popMatrix();
}
}
blendMode(SCREEN);
float[] colorRange = new float[2];
colorRange = calculateColorRange();
drawPixels(colorRange[0], colorRange[1]);
saveFrame("frames/####.png");
exit();
}
// For monochrome photo
float[] calculateColorRange() {
int divColor = 120;
int rangeColor = 360 / divColor;
float threshold = 0.95 * img.width * img.height;
int[] numColor;
numColor = new int[divColor];
for (int i = 0; i < divColor; ++i) {
numColor[i] = 0;
}
for (int idxW = 0; idxW < img.width; ++idxW) {
for (int idxH = 0; idxH < img.height; ++idxH) {
float pixColor = hue(img.pixels[idxH * img.width + idxW]);
if (pixColor == 360) {
pixColor = 0;
}
++numColor[int(pixColor / rangeColor)];
}
}
int[] copyArray = Arrays.copyOf(numColor, numColor.length);
Arrays.sort(copyArray);
int minValue = 0;
float sumValue = 0.0;
for (int i = divColor - 1; i >= 0; --i) {
sumValue += copyArray[i];
if (sumValue > threshold) {
minValue = copyArray[i];
break;
}
}
int minIdx = -1;
int maxIdx = divColor;
for (int i = 0; i < divColor; ++i) {
if (numColor[i] >= minValue) {
maxIdx = i;
if (minIdx == -1) {
minIdx = i;
}
}
}
return new float[]{minIdx * rangeColor, (maxIdx + 1) * rangeColor};
}
void drawPixels(float minColor, float maxColor) {
int idxDiv = 1;
float thresholdBright = 85.0;
float variRotation = map(maxColor - minColor, 360.0, 0.0, 45.0, 90.0); // For monochrome photo
float variColor = 50;
if (maxColor - minColor < 180) {
// For monochrome photo
variColor = map(maxColor - minColor, 0, 180, 180, 90);
}
float noiseW = random(50.0);
float startNoiseH = random(50.0);
noFill();
strokeWeight(0.1);
for (int idxW = 0; idxW < img.width; idxW += idxDiv) {
float noiseH = startNoiseH;
for (int idxH = 0; idxH < img.height; idxH += idxDiv) {
int idxPoint = idxH * img.width + idxW;
color cPoint = img.pixels[idxPoint];
if (brightness(cPoint) < thresholdBright) {
float baseColor = round((map(hue(cPoint), minColor, maxColor, 0, 360) % 360) / 20) * 20;
float brightToColor = map(brightness(cPoint), 0, thresholdBright, -variColor, variColor);
float valHue = (baseColor + brightToColor + 360) % 360;
float valSat = map(brightness(cPoint), 0.0, thresholdBright, 40.0, 100.0);
float valBri = map(brightness(cPoint), 0.0, thresholdBright, 40.0, 0.0);
float valAlp = map(brightness(cPoint), 0.0, 100.0, 50.0, 100.0);
float valSize = map(brightness(cPoint), 0.0, thresholdBright, 0.0, 50.0 * idxDiv);
float brightToRad = map(brightness(cPoint), 0.0, thresholdBright, 0.0, 360.0);
float saturateToRad = map(saturation(cPoint), 0.0, 100.0, 0.0, 360.0);
float noiseRad = map(noise(noiseW, noiseH), 0.0, 1.0, -variRotation, variRotation);
float valRotate = brightToRad + saturateToRad + noiseRad;
pushMatrix();
translate(idxW, idxH);
rotate(radians(valRotate % 360.0));
stroke(valHue, valSat, valBri, valAlp);
line(0.0, -valSize, 0.0, valSize);
popMatrix();
}
noiseH += 0.008;
}
noiseW += 0.008;
}
}
/*
Copyright (C) 2020- 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/>
*/
Example code version 0.2.
// Mewstique. // @author @deconbatch // @version 0.2 // Processing 3.2.1 // 0.1 2017.06.21 // 0.2 2018.12.23 : add background image drawing. import java.util.Arrays; /* ---------------------------------------------------------------------- */ 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 LineBrush extends PshapeElement { LineBrush() { super(); } PShape pscreateElement() { noFill(); PShape psDp = createShape(LINE, -1.5, -1.5, 1.5, 1.5); return psDp; } } /* ---------------------------------------------------------------------- */ PImage img; PshapeElement brush; float canvasW, canvasH; void setup() { size(1080, 1080); float baseWH = 980; colorMode(HSB, 360, 100, 100, 100); blendMode(SCREEN); strokeWeight(0.0001); smooth(8); noLoop(); brush = new LineBrush(); 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 float 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.0, 90.0, 0.0); translate((width - canvasW) / 2, (height - canvasH) / 2); // Draw background blendMode(BLEND); float maxBrightness = 20.0; float maxSaturation = 100.0; for (int idxW = 0; idxW < img.width; ++idxW) { for (int idxH = 0; idxH < img.height; ++idxH) { int idxPoint = idxH * img.width + idxW; color cPoint = img.pixels[idxPoint]; float valSiz = random(2.0, 10.0); float valRotate = map(random(1.0), 0.0, 1.0, -90.0, 90.0); float valHue = hue(cPoint); float valSat = map(saturation(cPoint), 0.0, 100.0, 0.0, maxSaturation); float valBri = map(brightness(cPoint), 0.0, 100.0, 0.0, maxBrightness); float valAlp = 100.0; pushMatrix(); translate(idxW, idxH); brush.resetSize(); brush.changeSize(valSiz, valSiz); brush.rotate(radians(valRotate)); brush.setElementFill(valHue, valSat, valBri, valAlp); brush.show(); popMatrix(); } } blendMode(SCREEN); float[] colorRange = new float[2]; colorRange = calculateColorRange(); drawPixels(colorRange[0], colorRange[1]); saveFrame("frames/####.png"); exit(); } // For monochrome photo float[] calculateColorRange() { int divColor = 120; int rangeColor = 360 / divColor; float threshold = 0.95 * img.width * img.height; int[] numColor; numColor = new int[divColor]; for (int i = 0; i < divColor; ++i) { numColor[i] = 0; } for (int idxW = 0; idxW < img.width; ++idxW) { for (int idxH = 0; idxH < img.height; ++idxH) { float pixColor = hue(img.pixels[idxH * img.width + idxW]); if (pixColor == 360) { pixColor = 0; } ++numColor[int(pixColor / rangeColor)]; } } int[] copyArray = Arrays.copyOf(numColor, numColor.length); Arrays.sort(copyArray); int minValue = 0; float sumValue = 0.0; for (int i = divColor - 1; i >= 0; --i) { sumValue += copyArray[i]; if (sumValue > threshold) { minValue = copyArray[i]; break; } } int minIdx = -1; int maxIdx = divColor; for (int i = 0; i < divColor; ++i) { if (numColor[i] >= minValue) { maxIdx = i; if (minIdx == -1) { minIdx = i; } } } return new float[]{minIdx * rangeColor, (maxIdx + 1) * rangeColor}; } void drawPixels(float minColor, float maxColor) { int idxDiv = 1; float thresholdBright = 85.0; float variRotation = map(maxColor - minColor, 360.0, 0.0, 45.0, 90.0); // For monochrome photo float variColor = 50; if (maxColor - minColor < 180) { // For monochrome photo variColor = map(maxColor - minColor, 0, 180, 180, 90); } float noiseW = random(50.0); float startNoiseH = random(50.0); for (int idxW = 0; idxW < img.width; idxW += idxDiv) { float noiseH = startNoiseH; for (int idxH = 0; idxH < img.height; idxH += idxDiv) { int idxPoint = idxH * img.width + idxW; color cPoint = img.pixels[idxPoint]; if (brightness(cPoint) < thresholdBright) { float baseColor = round((map(hue(cPoint), minColor, maxColor, 0, 360) % 360) / 20) * 20; float brightToColor = map(brightness(cPoint), 0, thresholdBright, -variColor, variColor); float valHue = (baseColor + brightToColor + 360) % 360; float valSat = map(brightness(cPoint), 0.0, thresholdBright, 90.0, 40.0); float valBri = map(brightness(cPoint), 0.0, thresholdBright, 28.0, 5.0); float valAlp = map(brightness(cPoint), 0.0, 100.0, 50.0, 100.0); float valSize = map(saturation(cPoint), 0.0, 100.0, 16.0 * idxDiv, 4.0 * idxDiv); float brightToRad = map(brightness(cPoint), 0.0, thresholdBright, 0.0, 360.0); float saturateToRad = map(saturation(cPoint), 0.0, 100.0, 0.0, 360.0); float noiseRad = map(noise(noiseW, noiseH), 0.0, 1.0, -variRotation, variRotation); float valRotate = brightToRad + saturateToRad + noiseRad; pushMatrix(); translate(idxW, idxH); brush.resetSize(); brush.changeSize(valSize, valSize); brush.rotate(radians(valRotate)); brush.setElementFill(valHue, valSat, valBri, valAlp); brush.show(); popMatrix(); } noiseH += 0.008; } noiseW += 0.008; } } /* 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/> */