Anda di halaman 1dari 5

Evaluasi Tengah Semester

Grafika Komputer

Nama : Muhammad Dhafi Eka Ramadan


NBI : 1462100212
Kelas : S (sore)
Matkul : Grafika Komputer
Tugas : ETS

Link P5JS :

https://editor.p5js.org/muhammaddhafi7/sketches/vR4d6D3XX

Link Video :

https://youtu.be/CK79fhYBePI

Hasil Pengolahan Citra :


Source Code :

function preload(){

foto = loadImage('suprit.jpg');

fotoGrey = createImage(360, 360);

fotoSepia = createImage(360, 360);

fotoNegative = createImage(360, 360);

function setup() {

createCanvas(720, 720);

warnaAsli = color(0);

warnaOlah = color(0);

merahOlah = color(0);

hijauOlah = color(0);

biruOlah = color(0);

noLoop();

function draw() {

background(255);

foto.resize(360, 360);

fotoGrey.loadPixels

for(let i = 0; i < foto.width; i++)

for(let j = 0; j < foto.height; j++)

warnaAsli = foto.get(i, j);


merahOlah = red(warnaAsli) * 0.21;

hijauOlah = green(warnaAsli) * 0.72;

biruOlah = blue(warnaAsli) * 0.07;

warnaOlah = color((merahOlah + hijauOlah + biruOlah) / 3);

fotoGrey.set(i, j, warnaOlah);

fotoGrey.updatePixels();

fotoSepia.copy(foto, 0, 0, foto.width, foto.height, 0, 0, foto.width, foto.height);

fotoSepia.filter(POSTERIZE, 64);

fotoSepia.loadPixels(360, 360);

for (let i = 0; i < fotoSepia.width * fotoSepia.height; i++) {

let r = fotoSepia.pixels[i * 4];

let g = fotoSepia.pixels[i * 4 + 1];

let b = fotoSepia.pixels[i * 4 + 2];

fotoSepia.pixels[i * 4] = r * 0.393 + g * 0.769 + b * 0.189;

fotoSepia.pixels[i * 4 + 1] = r * 0.349 + g * 0.686 + b * 0.168;

fotoSepia.pixels[i * 4 + 2] = r * 0.272 + g * 0.534 + b * 0.131;

fotoSepia.updatePixels();

fotoNegative.copy(foto, 0, 0, foto.width, foto.height, 0, 0, foto.width,foto.height);

fotoNegative.filter(POSTERIZE, 64);

fotoNegative.loadPixels(360, 360);

for (let i = 0; i < fotoNegative.width * fotoNegative.height; i++) {


let r = fotoNegative.pixels[i * 4];

let g = fotoNegative.pixels[i * 4+1];

let b = fotoNegative.pixels[i * 4+2];

fotoNegative.pixels[i * 4] = 255 - r;

fotoNegative.pixels[i * 4 + 1] = 255 - g;

fotoNegative.pixels[i * 4 + 2] = 255 - b;

fotoNegative.updatePixels();

image(foto, 0, 0);

textSize(50);

fill("yellow");

textFont('Times New Roman');

text("Foto Asli", 50, 60);

image(fotoGrey, 360,0);

textSize(50);

textFont('Times New Roman');

text("Foto Grey", 450, 60);

image(fotoSepia, 0,360);

textSize(50);

textFont('Times New Roman');

text("Foto Sepia", 50, 450);

image(fotoNegative, 360,360);

textSize(40);

textFont('Times New Roman');

text("Foto Negative", 430, 450);


}

Anda mungkin juga menyukai