Category Project-09-Portrait

sketch.js

//Hanna Jang 
//hannajan@andrew.cmu.edu
//Section B 
//Project -09

var underlyingHanna;
var randommax=13;

function preload() {
    var myImageURL = "https://i.imgur.com/v5rsvnH.jpg?1";
    underlyingHanna = loadImage(myImageURL);
}

function setup() {
    createCanvas(500, 500);
    background(255);
    underlyingHanna.loadPixels();
    frameRate(40);
}

function draw() {
    var px = random(width);	//random y from canvas width
    var py = random(height);	//random x from canvas height
    var thex = constrain(floor(px), 0, width-1);
    var they = constrain(floor(py), 0, height-1);
    var theColorAtLocationXY = underlyingHanna.get(thex, they); //var color from image background 

    noStroke();
    fill(theColorAtLocationXY);
    
    //make smiley face 
    
    //happy mouth is made 
  arc(px, py, 10, 10, 0, PI); 
  
  //happy eyes are made 
  ellipse(px-3, py-5, 5, 5); 
  ellipse(px+3, py-5, 5, 5); 

	//when mouse moves, a trail of squares follow 
    var theColorAtTheMouse = underlyingHanna.get(mouseX, mouseY);
	stroke(theColorAtTheMouse);
	rect(mouseX, mouseY, 3, 3);
}

function mousePressed(){
	//random sizes for sad face generation from mouse press 
	var sizex=random(7,randommax); 
	var sizey=random(7, randommax); 
	 var Mousecolor = underlyingHanna.get(mouseX, mouseY);

	//sad mouth is made 
	 fill(Mousecolor);
    arc(mouseX, mouseY, sizex, sizey, PI, TWO_PI); 
    //sad eyes are made 
    ellipse(mouseX-3, mouseY-10, 5, 5); 
    ellipse(mouseX+3, mouseY-10, 5, 5); 
}

I decided to do a self-portrait image background of me smiling into the camera. I then thought of an idea to use faces for the custom pixels, to make up a bigger picture of a smiling face.

Original image draft
original picture
screenshot of partly finished portrait
fully finished portrait

hschung-LookingOutwards-09

I looked at my friend Tiffany’s post about Marpi’s meditative installation art named “The Wave.” The display uses open source shaders by Jaume Sanchez powered by Three.js. It’s a serene, sizeable touchscreen display of waves, made up of soft, curved shapes and strokes. People can interact with the display and guide the movement of the water particles. I wasn’t sure if they really behaved like water particles, but it’s interesting that Marpi calls the shapes water particles; though the shape and behavior doesn’t necessarily follow the behavior of real water, I can bring myself to believe that if we had magical powers to control water with gestures, that it would move in this manner. I agree with Tiffany that it’s a very pleasant and soothing visual to look at. The slow movement and soft curves are comforting and satisfying to watch as they change direction and shape. The video below showing people interacting with “The Wave” was posted a year ago.

The Wave from Marpi on Vimeo.

Link to my friend’s Looking Outwards post:

thlai-Looking-Outwards-05

svitoora – 08 Lines in the Dark

sketch

// Supawat Vitoorapakorn
// Svitoora@andrew.cmu.edu
// Section E

var face = "https://i.imgur.com/EyvV5mU.jpg"
var img;
var pixel_info = [];

// Createm Node
function new_pixel(x, y, k) {
	this.x = x;
	this.y = y;
	this.k = contrast_add(k, .25);
	this.m = map(k, 0, 255, 50, 1);
}


// Load links to image into an array
function preload() {
	img = loadImage(face)
}

w = 480;
h = w;

function setup() {
	createCanvas(w, h);
	background(255 * .75);
	image(img, 0, 0, w, h);

	// Extract Image info
	step = 1;
	for (Y = 0; Y < w; Y += step) {
		for (X = 0; X < h; X += step) {
			k = brightness(get(X, Y));
			// print(X, Y, k);
			pixel_info.push(new new_pixel(X, Y, k));
			step = random(7, 10)
		}
	}

	// Sort pixels by brightness
	pixel_info.sort(function(a, b) {
		return a.k - b.k
	});

	// Print info and clear screen
	print(pixel_info);
	background(255 * .2);

	// Draw
	noStroke();
	print(pixel_info.length)
	draw_face(.9);
	add_lines();
	draw_face(.2);
}

// Draw Face
function draw_face(opacity) {
	for (i in pixel_info) {
		x = pixel_info[i].x;
		y = pixel_info[i].y;
		k = pixel_info[i].k;

		r = map(k, 0, 255, 15, 1);

		noStroke();
		fill(k, k, k, 255 * opacity);
		ellipse(x, y, r, r);
	}
}

// Increase contrast
// x is input
// k is percent e.g. 0.1
function contrast_add(x, p) {
	if (x < 255 / 2) {
		x = x * (1 + p);
	} else {
		x = x * (1 - p);
	}
	return x
}

// Add lines for sophistication
function add_lines() {
	for (i in pixel_info) {
		x = pixel_info[i].x;
		y = pixel_info[i].y;
		k = pixel_info[i].k;
		for (i in pixel_info) {
			x1 = pixel_info[i].x;
			y1 = pixel_info[i].y;
			k1 = pixel_info[i].k;
			if (round(k) == round(k1)) {
				strokeWeight(1);
				stroke(k, k, k, 255 * .05);
				line(x, y, x1, y1);
			}
		}
	}
}

Portrait

I was experiencing some dark times in my life, therefore I decided to make a dark portrait. I was inspired by the algorithmic portrait.

I tried to replicate the portrait above, but sadly I couldn’t do in time. Since my portrait is a bit computationally heavy, here is a still image of it:

SaveSave

SaveSave

nayeonk1-LookingOutwards-09

Jiaxin wrote a blog post about CG artist Cornelius Dämmrich. His works look like awesome illustrations, but he uses multiple graphic softwares to create lighting, texture and shading. Since I have interest on concept art, this blog post just caught my eyes. Jiaxin said there is no specific story behind his work, but as I see, I can read the story behind it. Story doesn’t necessarily mean to have narrative. If it has detailed concept for background and atmosphere, it can be a story too. In his work, amount of details tell a lot of things. I love how he uses lighting to tell a story. Strong contrast from the image gives a feeling on isolation, and also antipation for something.

Here are more images I found on his websites.

Until the light takes us 2013(in progress)
Until the light takes us 2013(Final work)

Jiaxin’s post
Cornelius Dammrich’s website

Nayeon-Project09-Portrait

nayeonk1

var portrait;

//image loading from imgur
function preload() {
    var imageURL = "https://i.imgur.com/WgHeMvC.jpg";
    portrait = loadImage(imageURL);
}

//setup loadPixel function here & setup frame Rate(speed)
function setup() {
    createCanvas(480, 480);
    background(0);
    portrait.loadPixels();
    frameRate(20);
}

//draw stitches and ellipses changing there size and length depend on mouse position
function draw() {
    var px = random(width);
    var py = random(height);
    var px1 = random(width);
    var py1 = random(height);
    var ix = constrain(floor(px), 0, width);
    var iy = constrain(floor(py), 0, height);
    var col = portrait.get(ix, iy);
    var dia = round(constrain(mouseX / 5, 0, 15))
    var len = round(constrain(mouseY / 5, 0, 10))
//ellipse
    noStroke();
    fill(col);
    ellipse(px, py, dia, dia)
//stitches
    stroke(col);
    strokeWeight(random(0.5, 2))
    line(px1, py1, px1 + len, py1 + len);
    line(px1 + len, py1, px1, py1 + len);
    pop();

}

I choose one of the photos from a last year trip to japan. It was fun and interesting trip. So I wanted to make this pixel loading image to be shine as the memory.
Here are some images of portrait.

jdperez Project 9

This project was SO MUCH FUN. I had way too many ideas for just this week, so after I finish this post I’ll probably go back to making portraits.

At first I had only abstract concepts to work towards. Like gravity was definitely something I wanted to play around with. Unfortunately, I ran into issues with how ridiculously long it took to load the program every time I ran it…. there was no way I was going to be able to make anything that complicated. I was worried that I might not even finish the project! (every time I loaded the image it took on average 7 minutes to load. That’s like 8 an hour).

So, a good portion of my work on this project was figuring out how to make it run faster. After reading around on the reference page, I figured out if I used loadPixels, I could directly access the pixels[] array, and thus get the pixels information way faster. And.. hurray the code runs almost instantly!

I had a couple hours left, so I didn’t have room to be QUITE as ambitious as I wanted to be for this project (I was honestly going to turn in like 5 different codes as variations on a theme). Nonetheless, I think it turned out pretty well. I wanted to get a sort of old video game aesthetic going, so first I coded that up.

 

First step in the process. transforming the image into these block-ey pixels and getting the contrast right.

I played around with the size of the squares used to create the image, and the contrast between the darker parts (like the hair and lips) and the lighter parts (skin), but ultimately settled on the image above. Next, I (accidentally) made the stroke() color on the square pixels 10 below the fill color. This gave the image a more tile-esque look to it — closer to that old video game vibe I was going for. I decided to play around with that (intentionally this time), and settled on a white stroke. The reason being, is I wanted to print out the image on a huge poster, and have the affect of a bunch of separated squares, instead of a filled canvas.

Second step in the process. I was playing around with adding a border around the block pixels, and decided I liked the white border.

At this point, I felt like the portrait was pretty good, but I wanted to do something a little bit more. Also, I just wanted to do something with code that is a bit out of my comfort zone… so I implemented objects into the portrait. I made each “tile” start at the bottom of the canvas, and slide upwards at varying speeds until it reached its correct location on the canvas.

I particularly like the effect that occurs around the bottom of the hair, as the dark pixels are sliding under the lighter pixels that have already reached their destination.

Click the in the image below if you want to see the program run again!

sketch

//Jonathan Perez
//Section B
//jdperez@andrew.cmu.edu
//Project 9

var img;
var rectSize = 9 //size of square pixels
var margin = 1 //gap between square pixels


function preload() {
    img = loadImage("https://i.imgur.com/DjcKS6b.jpg");
}

function myTile(x, y, finalY, dy, color) {
    this.x = x
    this.y = y
    this.finalY = finalY
    this.dy = dy
    this.color = color
    this.draw = function() {
        rectMode(CENTER);
        stroke(255);
        strokeWeight(margin+1) // creates a white border around the tiles for visual emphasis and irregularity
        rect(this.x, this.y, rectSize, rectSize);
    };

    this.move = function() {
        if(this.y > this.finalY) {
            this.y = this.y - this.dy; //move the tile upwards
        }
        
    };
}

var myTile
var allTiles = [];

function setup() {
    createCanvas(img.width, img.height);
    background(200); 
    pixelDensity(1); //scales pixelDensity to image
    image(img, 0, 0)
    loadPixels(); //loads pixel array
    for(y = 0; y < img.height; y += rectSize+margin) { //scans through one row at a time from top to bottom
        for(x = 0; x < img.width; x += rectSize+margin) { //scans through all of the pixels in the row
            var d = pixelDensity();
            var off = (y * width + x) * d * 4; //location of the R value of x and y coordinate in pixel array
            var bright = pixels[off];
            
            if(bright  < 30) { //checks current pixels brightness against current brightest pixel
                allTiles.push(new myTile(x, height+(rectSize/2), y, random(2,4), 0));
            } else if(bright < 40 & bright >= 30) {
                allTiles.push(new myTile(x, height+(rectSize/2), y, random(2,4), 20));
            } else if(bright < 60 & bright >= 40) {
                allTiles.push(new myTile(x, height+(rectSize/2), y, random(2,4), 40));
            } else if(bright < 70 & bright >= 60) {
                allTiles.push(new myTile(x, height+(rectSize/2), y, random(2,4), 60));
            } else if(bright < 80 & bright >= 70) {
                allTiles.push(new myTile(x, height+(rectSize/2), y, random(2,4), 70));
            } else if(bright < 90 & bright >= 80) {
                allTiles.push(new myTile(x, height+(rectSize/2), y, random(2,4), 130));
            } else if(bright < 100 & bright >= 90) {
                allTiles.push(new myTile(x, height+(rectSize/2), y, random(2,4), 140));
            } else if(bright < 110 & bright >= 100) {
                allTiles.push(new myTile(x, height+(rectSize/2), y, random(2,4), 140));
            } else if(bright < 120 & bright >= 110) {
                allTiles.push(new myTile(x, height+(rectSize/2), y, random(2,4), 150));
            } else if(bright < 130 & bright >= 120) {
                allTiles.push(new myTile(x, height+(rectSize/2), y, random(2,4), 160));
            } else if(bright < 140 & bright >= 110) { //switch from lower bound to upper bound
                allTiles.push(new myTile(x, height+(rectSize/2), y, random(2,4), 175));
            } else if(bright < 170 & bright >= 140) {
                allTiles.push(new myTile(x, height+(rectSize/2), y, random(2,4), 210));
            } else if(bright < 200 & bright >= 170) {
                allTiles.push(new myTile(x, height+(rectSize/2), y, random(2,4), 220));
            } else if(bright < 220 & bright >= 200) {
                allTiles.push(new myTile(x, height+(rectSize/2), y, random(2,4), 230));
            } else if(bright < 240 & bright >= 220) {
                allTiles.push(new myTile(x, height+(rectSize/2), y, random(2,4), 250));
            } else if(bright < 260 & bright >= 240) {
                allTiles.push(new myTile(x, height+(rectSize/2), y, random(2,4), 255));
            }
            
        }
    }
    print(img.width, img.height)


}

function draw() {
    scale(.65);
    background(255);
    for(i = 0; i < allTiles.length; i++) {
        fill(allTiles[i].color);
        allTiles[i].draw();
        allTiles[i].move();
        
    }
}

function mouseClicked() {
    for(i = 0; i < allTiles.length; i++) {
        allTiles[i].y = height + rectSize/2
        
    }
}

Project 9, odh

odhP9

//Owen D Haft
//Section D
//odh@andrew.cmu.edu
//Project 9

var underlyingImage;
var pict;

function preload() {
    //Loads two different images:
    //Image 1
    var myImageURL = "https://i.imgur.com/AOEHv7s.jpg";
    //Image 2
    var myImageURL2 = "https://i.imgur.com/iGOj0Sd.jpg"; 
    underlyingImage = loadImage(myImageURL);
    underlyingImage2 = loadImage(myImageURL2);
}

function setup() {
    createCanvas(480, 480);
    background(0);
    underlyingImage.loadPixels();
    underlyingImage2.loadPixels();
    frameRate(60);
    pict = random(1,2);
}

function draw() {
    var px = random(width);
    var py = random(height);
    var ix = constrain(floor(px), 0, width-1);
    var iy = constrain(floor(py), 0, height-1);
    //"gets" the pixels color in each image
    var theColorAtLocationXY = underlyingImage.get(ix, iy);

    //Draws Randomly sized, randomly located rectangles reflecting the colors in image 1
    noStroke();
    fill(theColorAtLocationXY);
    rect(px, py, random(1, 10), random(1, 10));

    //Draws a line the follows the mouses location that reflects the colors in image 2
    var theColorAtTheMouse = underlyingImage2.get(mouseX, mouseY);
    stroke(theColorAtTheMouse);
    strokeWeight(10);
    line(pmouseX, pmouseY, mouseX, mouseY);
}

I chose to have different photos in my portrait, each revealed and shown in different ways. One image is revealed with random varying sized rectangles and the other with the mouse with ellipses. One appears cubist-like, and the other more expressionist.

Both shown finished:

monicah1-project-09-SectionA

 

sketch


var frames = []; // An array to store the images
var characterX;  // The X location of the character
var characterY;  // The Y location of the character
var targetX;     // The X goal, from the user's click
var targetY;     // The Y goal, from the user's click
var exampleImgOnly; 

 
//---------------------------------------
function preload(){
  
    // These URLs are for the individual walk cycle images,
    // stored in the imgur album http://imgur.com/a/85DTu
    var filenames = [];
    filenames[0] = "http://i.imgur.com/svA3cqA.png";
    filenames[1] = "http://i.imgur.com/jV3FsVQ.png";
    filenames[2] = "http://i.imgur.com/IgQDmRK.png";
    filenames[3] = "http://i.imgur.com/kmVGuo9.png";
    filenames[4] = "http://i.imgur.com/jcMNeGq.png";
    filenames[5] = "http://i.imgur.com/ttJGwkt.png";
    filenames[6] = "http://i.imgur.com/9tL5TRr.png";
    filenames[7] = "http://i.imgur.com/IYn7mIB.png";
  
  
    // LOAD THE IMAGES INTO THE frames ARRAY,
    // USING THE FILENAMES STORED IN THE filenames ARRAY.
    for (var i = 0; i < filenames.length; i++){
    	frames.push(loadImage(filenames[i]));
    } 
}
 
//---------------------------------------
function draw() {
    background(222);
  
    // MOVE THE CHARACTER TOWARDS THE TARGET.
    var dx = targetX - characterX;
    var dy = targetY - characterY;
    var distanceFromCharacterToTarget = sqrt(dx*dx + dy*dy);
  
  
    // DISPLAY THE CHARACTER, CYCLING THROUGH THE FRAMES.
    image(frames[frameCount%8], characterX, characterY);
    
    // FLIP THE IMAGE IF THE CHARACTER'S HEADING LEFT. 
    /*if(mouseX < targetX){
        image= scale(filesnames, -1,1);
    }
    image*/
    // Don't touch this:
    // Draw a spot at the target, colored based on the character's proximity. 
    drawTargetEllipse (distanceFromCharacterToTarget);
    characterX = lerp(characterX,targetX,0.1);
    characterY = lerp(characterY,targetY,0.1);
}
 
 
//=======================================================
// PROBABLY NO REASON TO CHANGE ANYTHING BELOW THIS LINE. 
function setup() {
    createCanvas(800, 480);
    imageMode(CENTER);
    frameRate(12);
  
    // Initialize the character and target positions. 
    characterX = width / 2; 
    characterY = height / 2; 
    targetX = characterX;
    targetY = characterY;
}
 
//---------------------------------------
function drawTargetEllipse(distanceFromCharacterToTarget){
    if (distanceFromCharacterToTarget < 80){
        fill(0,200,0, 40); // Green if we're nearby
    } else {
        fill(255,0,0, 40); // Red if we're far away
    }
    noStroke();
    ellipse(targetX, targetY, 160,160); 
}
 
//---------------------------------------
function mousePressed() {
    targetX = mouseX;
    targetY = mouseY;
}

This is a portrait of my grand-grand-father. The effect of slowly revealing  pixels of the portrait brings in the sense of history and senses. I almost want the picture to become three dimensional and see my grand-grand-father in reality.

gyueunp – Project-09: Computational Portrait

computational portrait (custom pixel)

//GyuEun Park
//gyueunp@andrew.cmu.edu
////15-104 E
//Project-09

var image;

//load image using an imgur url
function preload() {
    var myImageURL = "https://i.imgur.com/epczjju.jpg";
    image = loadImage(myImageURL);
}

function setup() {
    createCanvas(480, 274);
    background(0);
    image.loadPixels();
    frameRate(2000);
}

function draw() {
//set colors and positions for ellipses to create the image 
    var px = random(width);
    var py = random(height);
    var ps = random(0.5,10);
    var ix = constrain(floor(px), 0, width-1);
    var iy = constrain(floor(py), 0, height-1);
    var theColorAtLocationXY = image.get(ix, iy);

    noStroke();
    fill(theColorAtLocationXY);
    ellipse(px, py, ps, ps);
}

This project resembles pointillist artworks in that the dots of color gather to form an image. In this case, I chose to use a photo of myself. I love how oddly unsettling the dots are as they grow into my body. The auditory element also adds on to the disturbing nature of the work.

 

hannahk2-Project-09

sketch

//Hannah Kim
//Section A
//hannahk2@andrew.cmu.edu
//Project-09

var img;
var small, big;

function preload() {
  var myImageURL = "https://i.imgur.com/7sW6Was.jpg";
	img = loadImage(myImageURL);
}

function setup() {
  createCanvas(500, 400);
  small = 4;
  big = 30;
  imageMode(CENTER);
  noStroke();
  background(0);
  img.loadPixels();
}

function draw() {
  var pointCircle = map(mouseX, 0, 250, small, big);
  var pointSquare = map(mouseX, 250, width, small, big);
  var x = floor(random(img.width));
  var y = floor(random(img.height));
  var pix = img.get(x, y);
  fill(pix, 100);
  if(mouseX<240){
  ellipse(x, y, pointCircle, pointCircle);
  fill(0);
  ellipse(x, y, pointCircle-5, pointCircle-5);

  } else {
  fill(pix, 100);
  rect(x, y, pointSquare, pointSquare);
  }

}

 

There were a few versions I messed around with before coming to my final version. I chose to create a portrait of my sister.

Below is an image of the final result which I felt was the most visually interesting.

 

Below are my other iterations.

The first one on the bottom was personally my favorite, however I felt it wasnt as interesting as the image above.