Cells
In the cellular automata the Morley Algorithm allows for a static "object" to occur in the above formation, however that is not the focus of this post. Instead we will be using the above geometry in order to create a basic smoothing algorithm using PImage in Processing. This post continues the Algorithm outlined in the previous post Statistically Viable Time Based Smoothing and Deconvolution AlgorithmPImage img; int a, b,r,u;This sets up the image variable and the 4 vars we will be using.
void setup() { size(500, 500); img = loadImage("cat.jpg"); a = 1; b = 1; r=img.width; u=0; imageMode(CENTER); noStroke(); background(0); }Loading the image and setting up our variables. a & b are for rect sides or in terms of the above image they are the size of the white pieces.
void draw() { float pixel = map(11, 0, width, a, b); //creating pixel variable int x = int((img.width)-r); // sets the x pt equal to image width minus the
//size of the r val which paints the image int y= int(u);//u as the y val due, tis necessary due to language syntax color pix = img.get(x, y);//captures pixel color fill(pix, 128);//color,alphamask
rect(x-1, y, pixel, pixel); rect(x+1, y, pixel, pixel); rect(x, y-1, pixel, pixel); rect(x, y+1, pixel, pixel);//these rect lines create our Cells diagram r=r-1;//moves painting along the x axis println(r);//outputs current pos Now there must be an if statement in order to move along the y axis once a row is completed:
if(r==1000){ r=img.width; u=u+1; } } And so the symphony all together:
PImage img; int a, b,r,u; void setup() { size(500, 500); img = loadImage("cat.jpg"); a = 1; b = 1; r=img.width; u=0; imageMode(CENTER); noStroke(); background(0); } void draw() { float pixel = map(11, 0, width, a, b); int x = int((img.width)-r); int y= int(u); color pix = img.get(x, y); fill(pix, 128); rect(x-1, y, pixel, pixel); rect(x+1, y, pixel, pixel); rect(x, y-1, pixel, pixel); rect(x, y+1, pixel, pixel); r=r-1; println(r); if(r==1000){ r=img.width; u=u+1; } }
The Cat's Ear without smoothing
The Cat's Ear with Cluster Smoothing
A place where the smoothing is perhaps most noticeable is in blue background, notice the falloff occurs quickly on the smoothed image but not nearly as quickly on the non-smoothed image. That is because the novel method ensures blending of the regions which guarantees blending and the elimination of noise in the image.
No comments:
Post a Comment