• Tidak ada hasil yang ditemukan

MAKALAH PROSES PEMBUATAN RGB PADA SISTEM

N/A
N/A
Protected

Academic year: 2018

Membagikan "MAKALAH PROSES PEMBUATAN RGB PADA SISTEM"

Copied!
41
0
0

Teks penuh

(1)

MAKALAH

PROSES PEMBUATAN RGB PADA

SISTEM DIGITAL

Oleh:

Moh Erwan Agus Saputra

111080200199

FAKULTAS TEKNIK

JURUSAN TEKNIK INFORMATIKA

UNIVERSITAS MUHAMMADIYAH SIDOARJO

2014

(2)

SKRIP GAMBAR AWAL

<div align="center"></div>

<?php

error_reporting(0);

//============ PENGOLAHAN CITRA 24 BIT ========= /*

Berikut ini adalah contoh coding mengkases citra dan menyimpannya kedalam array berbasi structure/variabel-buatan..

*/

$dewi="asli.jpg"; //nama gambar yang diambil $hasil = getimagesize($dewi); // ukuran awal gambar if(! $hasil)

{

die("File $citra tidak dapat dibuka"); }

else {

//tampilkan informasi data citra print("<IMG SRC=\"$dewi\">"); print("<P>");

print("Lebar Citra = $hasil[0] <BR>\n"); print("Tinggi Citra = $hasil[1] <BR>\n"); print("Tipe Citra = $hasil[2] <BR>\n"); print("String Citra = $hasil[3] <BR>\n"); }

$gb=imagecreatefromJPEG($dewi); //membuat gambar yang berasal dari sebuah URL ataupun nama sebuah file

(3)

list($lebar, $tinggi, $type, $attr) = getimagesize($dewi);

//yang akan menghasilkan array informasi dari file gambar yang akan kita resize (yang diset melalui constructor)

//Tampilkan tinggi lebar citra echo "Image width " .$lebar; echo "<BR>";

echo "Image height " .$tinggi; echo "<BR>";

echo "Image type " .$type; echo "<BR>";

echo "Attribute " .$attr; //fungsi membaca citra *.PNG

$im = imagecreatefrompng("asli.jpg");//// Load gambar dasar kami $mhb = imagecolorat($im, 10, 15);

$r = ($mhb >> 16) & 0xFF; $g = ($mhb >> 8) & 0xFF; $b = $mhb & 0xFF; var_dump($r, $g, $b);

//untuk melihat proses di PHP //syntax membaca citra *.JPG $im = imagecreatefromjpeg($dewi); $mhb = imagecolorat($im, 10, 15); $r = ($mhb >> 16) & 0xFF;

$g = ($mhb >> 8) & 0xFF; $b = $mhb & 0xFF; //var_dump($r, $g, $b);

(4)

{

public $R; //untuk red public $G; //untuk green public $B; //untuk blue public $gray; //untuk gray public $teks; //misalnya }

//======================================== //contoh mengakses variabel biasa berbasis struct $data = new datamhb();

$data->R =30; $data->G =15; $data->B =244; $data->gray =40;

//CONTOH mengakses variabel Array D1 berbasis struct $dt[] = new datamhb();

$dt[1]->R =30; $dt[1]->G =15; $dt[1]->B =244; echo $dt[1]->gray =40;

//CONTOH mengakses variabel Array D2 berbasis struct $DATA[][] = new datamhb();

(5)

$im = imagecreatefromjpeg($dewi); $imred = imagecreatefromjpeg($dewi); $imgreen = imagecreatefromjpeg($dewi); $imblue = imagecreatefromjpeg($dewi); $x=0;

$dtmhb[][] = new datamhb(); for($x==0;$x<$lebar-1;$x++) {

$im = imagecreatefromjpeg($dewi); $y=0;

for($y==0;$y<$tinggi-1;$y++) {

//echo "y=". $y . ", x=" . $x . "</BR>"; //Ambil Data Citra

$mhb = imagecolorat($im, $x, $y);

//Get mhb disimpan dalam variabel biasa (JADUL) //$r = (int)(($mhb >> 16) & 0xFF); //mode JADUL $red[$x][$y] = (int)(($mhb >> 16) & 0xFF); $green[$x][$y] = (int)(($mhb >> 8) & 0xFF); $blue[$x][$y] = (int)($mhb & 0xFF);

$gray[$x][$y]= (int)(($r+$g+$b)/3);

(6)

//echo "Matrik [$x,$y] R=$r, G=$g, B=$b <BR>"; //tulis pixel

$gray = imagecolorallocate($im2, $dtmhb[$x][$y]->gray, $dtmhb[$x][$y]->gray, $dtmhb[$x] [$y]->gray);

$merah = imagecolorallocate($imred, $dtmhb[$x][$y]->R, 0, 0); $hijau = imagecolorallocate($imgreen, 0, $dtmhb[$x][$y]->G, 0); $biru = imagecolorallocate($imblue, 0, 0, $dtmhb[$x][$y]->B); // set $from to $to if hex matches.

imagesetpixel($imred, $x, $y, $merah); imagesetpixel($imgreen, $x, $y, $hijau); imagesetpixel($imblue, $x, $y, $biru); //imagesetpixel($imgray, $x, $y, $gray); }

} ?>

(7)

2.

Gambar RGB (BIRU)

<?php

error_reporting(0);

//============ PENGOLAHAN CITRA 24 BIT =========

/*

Berikut ini adalah contoh coding mengkases citra dan menyimpannya kedalam array berbasi structure/variabel-buatan..

*/

$dewi="asli.jpg";

$hasil = getimagesize($dewi);

if(! $hasil)

{

die("File $citra tidak dapat dibuka");

}

else

{

//tampilkan informasi data citra

//print("<IMG SRC=\"$dewi\">");

//print("<P>");

//print("Lebar Citra = $hasil[0] <BR>\n");

//print("Tinggi Citra = $hasil[1] <BR>\n");

//print("Tipe Citra = $hasil[2] <BR>\n");

//print("String Citra = $hasil[3] <BR>\n");

}

$gb=imagecreatefromJPEG($dewi);

//==== Baca Citra Ukuran Tinggi Lebar ===

(8)

//Tampilkan tinggi lebar citra

echo "Image width " .$lebar;

echo "<BR>";

echo "Image height " .$tinggi;

echo "<BR>";

echo "Image type " .$type;

echo "<BR>";

echo "Attribute " .$attr;

//fungsi membaca citra *.PNG

$im = imagecreatefrompng("asli.jpg");

$mhb = imagecolorat($im, 10, 15);

$m = ($mhb >> 16) & 0xFF;

$h = ($mhb >> 8) & 0xFF;

$b = $mhb & 0xFF;

var_dump($m, $h, $b);

//syntax membaca citra *.JPG

$im = imagecreatefromjpeg($dewi);

$mhb = imagecolorat($im, 10, 15);

$m = ($mhb >> 16) & 0xFF;

$h = ($mhb >> 8) & 0xFF;

$b = $mhb & 0xFF;

//var_dump($r, $g, $b);

//=== Variabel Buatan/Struc/Structure ====

class dataMHB

{

public $M; //untuk red

public $H; //untuk green

(9)

public $gray; //untuk gray

public $teks; //misalnya

}

//=======================================

//contoh mengakses variabel biasa berbasis struct

$data = new dataMHB();

$data->M =30;

$data->H =15;

$data->B =244;

$data->gray =40;

//CONTOH mengakses variabel Array D1 berbasis struct

$dt[] = new dataMHB();

$dt[1]->M =30;

$dt[1]->H =15;

$dt[1]->B =244;

echo $dt[1]->gray =40;

//CONTOH mengakses variabel Array D2 berbasis struct

$DATA[][] = new dataMHB();

$DATA[1][3]->M =30;

$DATA[1][3]->H =15;

$DATA[1][3]->B =244;

$DATA[1][3]->gray =40;

// ==== BACA RGB Citra =====

$im = imagecreatefromjpeg($dewi);

$imred = imagecreatefromjpeg($dewi);

$imgreen = imagecreatefromjpeg($dewi);

$imblue = imagecreatefromjpeg($dewi);

(10)

$x=0;

$dtMHB[][] = new dataMHB();

for($x==0;$x<$lebar-1;$x++)

{

$im = imagecreatefromjpeg($dewi);

$y=0;

for($y==0;$y<$tinggi-1;$y++)

{

//echo "y=". $y . ", x=" . $x . "</BR>";

//Ambil Data Citra

$mhb = imagecolorat($im, $x, $y);

//Get RGB disimpan dalam variabel biasa (JADUL)

//$r = (int)(($rgb >> 16) & 0xFF); //mode JADUL

$red[$x][$y] = (int)(($mhb >> 13) & 0xFF);

$green[$x][$y] = (int)(($mhb >> 8) & 0xFF);

$blue[$x][$y] = (int)($mhb & 0xFF);

$gray[$x][$y]= (int)(($m+$h+$b)/3);

//Simpan data RGB to Array berbasis Structure

$dtMHB[$x][$y]->M= (int)(($mhb >> 13) & 0xFF);

$dtMHB[$x][$y]->H= (int)(($mhb >> 8) & 0xFF);

$dtMHB[$x][$y]->B= (int)($mhb & 0xFF);

$dtMHB[$x][$y]->gray= (int)(($m+$h+$b)/3);

//tampilkan data RGB

//echo "Matrik [$x,$y] R=$r, G=$g, B=$b <BR>";

//tulis pixel

$gray = imagecolorallocate($im2, $dtMHB[$x][$y]->gray, $dtMHB[$x][$y]->gray, $dtMHB[$x][$y]->gray);

$merah = imagecolorallocate($imred, $dtMHB[$x][$y]->M, 0, 0);

(11)

$biru1 = imagecolorallocate($imblue1, 0, 0, $dtMHB[$x][$y]->B);

$biru = imagecolorallocate($imblue, 60, 80, $dtMHB[$x][$y]->B);

// set $from to $to if hex matches.

imagesetpixel($imred, $x, $y, $merah);

imagesetpixel($imgreen, $x, $y, $hijau);

imagesetpixel($imblue, $x, $y, $biru);

imagesetpixel($imblue1, $x, $y, $biru1);

//imagesetpixel($imgray, $x, $y, $gray);

}

}

echo"<br>";

echo"<br>";

imagepng($imblue1, "gambar.jpg");

imagedestroy($imblue1);

echo "Sebelum Proses Brightness";

$dewi="gambar.jpg";

print("<P>");

print("<IMG SRC=\"$dewi\">");

print("<P>");

//Simpan Citra Gray

imagepng($imblue, "biru.jpg");

imagedestroy($imblue);

$dewi="biru.jpg";

print("<P>");

print("<IMG SRC=\"$dewi\">");

print("<P>");

(12)

?>

(13)

3.

SKRIP RGB HIJAU

<?php

error_reporting(0);

//============ PENGOLAHAN CITRA 24 BIT =========

/*

Berikut ini adalah contoh coding mengkases citra dan menyimpannya kedalam array berbasi structure/variabel-buatan..

*/

$dewi="asli.jpg";

$hasil = getimagesize($dewi);

if(! $hasil)

{

die("File $citra tidak dapat dibuka");

}

else

{

//tampilkan informasi data citra

//print("<IMG SRC=\"$dewi\">");

//print("<P>");

//print("Lebar Citra = $hasil[0] <BR>\n");

//print("Tinggi Citra = $hasil[1] <BR>\n");

//print("Tipe Citra = $hasil[2] <BR>\n");

//print("String Citra = $hasil[3] <BR>\n");

}

$gb=imagecreatefromJPEG($dewi);

//==== Baca Citra Ukuran Tinggi Lebar ===

(14)

//Tampilkan tinggi lebar citra

echo "Image width " .$lebar;

echo "<BR>";

echo "Image height " .$tinggi;

echo "<BR>";

echo "Image type " .$type;

echo "<BR>";

echo "Attribute " .$attr;

//fungsi membaca citra *.PNG

$im = imagecreatefrompng("asli.jpg");

$mhb = imagecolorat($im, 10, 15);

$m = ($mhb >> 16) & 0xFF;

$h = ($mhb >> 8) & 0xFF;

$b = $mhb & 0xFF;

var_dump($m, $h, $b);

//syntax membaca citra *.JPG

$im = imagecreatefromjpeg($dewi);

$mhb = imagecolorat($im, 10, 15);

$m = ($mhb >> 16) & 0xFF;

$h = ($mhb >> 8) & 0xFF;

$b = $mhb & 0xFF;

//var_dump($r, $g, $b);

//=== Variabel Buatan/Struc/Structure ====

class dataMHB

{

(15)

public $H; //untuk green

public $B; //untuk blue

public $gray; //untuk gray

public $teks; //misalnya

}

//=======================================

//contoh mengakses variabel biasa berbasis struct

$data = new dataMHB();

$data->M =30;

$data->H =15;

$data->B =244;

$data->gray =40;

//CONTOH mengakses variabel Array D1 berbasis struct

$dt[] = new dataMHB();

$dt[1]->M =30;

$dt[1]->H =15;

$dt[1]->B =244;

echo $dt[1]->gray =40;

//CONTOH mengakses variabel Array D2 berbasis struct

$DATA[][] = new dataMHB();

$DATA[1][3]->M =30;

$DATA[1][3]->H =15;

$DATA[1][3]->B =244;

$DATA[1][3]->gray =40;

// ==== BACA RGB Citra =====

$im = imagecreatefromjpeg($dewi);

//$imred = imagecreatefromjpeg($dewi);

(16)

//$imblue = imagecreatefromjpeg($dewi);

$imgreen1 = imagecreatefromjpeg($dewi);

$x=0;

$dtMHB[][] = new dataMHB();

for($x==0;$x<$lebar-1;$x++)

{

$im = imagecreatefromjpeg($dewi);

$y=0;

for($y==0;$y<$tinggi-1;$y++)

{

//echo "y=". $y . ", x=" . $x . "</BR>";

//Ambil Data Citra

$mhb = imagecolorat($im, $x, $y);

//Get RGB disimpan dalam variabel biasa (JADUL)

//$r = (int)(($rgb >> 16) & 0xFF); //mode JADUL

$red[$x][$y] = (int)(($mhb >> 13) & 0xFF);

$green[$x][$y] = (int)(($mhb >> 8) & 0xFF);

$blue[$x][$y] = (int)($mhb & 0xFF);

$gray[$x][$y]= (int)(($m+$h+$b)/3);

//Simpan data RGB to Array berbasis Structure

$dtMHB[$x][$y]->M= (int)(($mhb >> 13) & 0xFF);

$dtMHB[$x][$y]->H= (int)(($mhb >> 8) & 0xFF);

$dtMHB[$x][$y]->B= (int)($mhb & 0xFF);

$dtMHB[$x][$y]->gray= (int)(($m+$h+$b)/3);

//tampilkan data RGB

//echo "Matrik [$x,$y] R=$r, G=$g, B=$b <BR>";

//tulis pixel

(17)

// $merah = imagecolorallocate($imred, $dtMHB[$x][$y]->M, 0, 0);

$hijau = imagecolorallocate($imgreen, 0, $dtMHB[$x][$y]->H, 0);

$hijau1 = imagecolorallocate($imgreen, 80, $dtMHB[$x][$y]->H, 80);

//$blue1 = imagecolorallocate($imblue1, 0, 0, $dtMHB[$x][$y]->B);

//$biru = imagecolorallocate($imblue, 60, 80, $dtMHB[$x][$y]->B);

// set $from to $to if hex matches.

//imagesetpixel($imred, $x, $y, $merah);

imagesetpixel($imgreen, $x, $y, $hijau);

//imagesetpixel($imblue, $x, $y, $biru);

imagesetpixel($imgreen1, $x, $y, $hijau1);

//imagesetpixel($imgray, $x, $y, $gray);

}

}

echo"<br>";

echo"<br>";

imagepng($imgreen1, "gambar.jpg");

imagedestroy($imgreen1);

echo "Sebelum Proses Brightness";

$dewi="gambar.jpg";

print("<P>");

print("<IMG SRC=\"$dewi\">");

print("<P>");

//Simpan data RGB to Array berbasis Structure

$dtMHB[$x][$y]->M= (int)(($mhb >> 13) & 0xFF);

$dtMHB[$x][$y]->H= (int)(($mhb >> 8) & 0xFF);

$dtMHB[$x][$y]->B= (int)($mhb & 0xFF);

$dtMHB[$x][$y]->gray= (int)(($m+$h+$b)/3);

(18)

//echo "Matrik [$x,$y] R=$r, G=$g, B=$b <BR>";

//tulis pixel

$gray = imagecolorallocate($im2, $dtMHB[$x][$y]->gray, $dtMHB[$x][$y]->gray, $dtMHB[$x][$y]->gray);

$merah = imagecolorallocate($imred, $dtMHB[$x][$y]->M, 0, 0);

$hijau = imagecolorallocate($imgreen, 0, $dtMHB[$x][$y]->H, 0);

$hijau1 = imagecolorallocate($imgreen1, 0, $dtMHB[$x][$y]->H, 0);

$biru1 = imagecolorallocate($imblue1, 0, 0, $dtMHB[$x][$y]->B);

$biru = imagecolorallocate($imblue, 60, 80, $dtMHB[$x][$y]->B);

// set $from to $to if hex matches.

imagesetpixel($imred, $x, $y, $merah);

imagesetpixel($imgreen, $x, $y, $hijau);

imagesetpixel($imblue, $x, $y, $biru);

imagesetpixel($imgreen1, $x, $y, $hijau1);

//imagesetpixel($imgray, $x, $y, $gray);

}

}

echo"<br>";

echo"<br>";

imagepng($imgreen1, "gambar.jpg");

imagedestroy($imgreen1);

echo "Sebelum Proses Brightness";

$dewi="gambar.jpg";

print("<P>");

print("<IMG SRC=\"$dewi\">");

print("<P>");

//Simpan Citra Gray

imagepng($imgreen, "hijau.jpg");

(19)

$dewi="hijau.jpg";

print("<P>");

print("<IMG SRC=\"$dewi\">");

print("<P>");

echo "Hasil Proses Brightness";

?>

(20)

4.

Skrip RGB (merah)

<?php

error_reporting(0);

//============ PENGOLAHAN CITRA 24 BIT =========

/*

Berikut ini adalah contoh coding mengkases citra dan menyimpannya kedalam array berbasi structure/variabel-buatan..

*/

$dewi="asli.jpg";

$hasil = getimagesize($dewi);

if(! $hasil)

{

die("File $citra tidak dapat dibuka");

}

else

{

//tampilkan informasi data citra

//print("<IMG SRC=\"$dewi\">");

//print("<P>");

//print("Lebar Citra = $hasil[0] <BR>\n");

//print("Tinggi Citra = $hasil[1] <BR>\n");

//print("Tipe Citra = $hasil[2] <BR>\n");

//print("String Citra = $hasil[3] <BR>\n");

}

$gb=imagecreatefromJPEG($dewi);

//==== Baca Citra Ukuran Tinggi Lebar ===

(21)

//Tampilkan tinggi lebar citra

echo "Image width " .$lebar;

echo "<BR>";

echo "Image height " .$tinggi;

echo "<BR>";

echo "Image type " .$type;

echo "<BR>";

echo "Attribute " .$attr;

//fungsi membaca citra *.PNG

$im = imagecreatefrompng("asli.jpg");

$mhb = imagecolorat($im, 10, 15);

$m = ($mhb >> 16) & 0xFF;

$h = ($mhb >> 8) & 0xFF;

$b = $mhb & 0xFF;

var_dump($m, $h, $b);

//syntax membaca citra *.JPG

$im = imagecreatefromjpeg($dewi);

$mhb = imagecolorat($im, 10, 15);

$m = ($mhb >> 16) & 0xFF;

$h = ($mhb >> 8) & 0xFF;

$b = $mhb & 0xFF;

//var_dump($r, $g, $b);

//=== Variabel Buatan/Struc/Structure ====

class dataMHB

{

public $M; //untuk red

public $H; //untuk green

(22)

public $gray; //untuk gray

public $teks; //misalnya

}

//========================================

//contoh mengakses variabel biasa berbasis struct

$data = new dataMHB();

$data->M =30;

$data->H =15;

$data->B =244;

$data->gray =40;

//CONTOH mengakses variabel Array D1 berbasis struct

$dt[] = new dataMHB();

$dt[1]->M =30;

$dt[1]->H=15;

$dt[1]->B =244;

echo $dt[1]->gray =40;

//CONTOH mengakses variabel Array D2 berbasis struct

$DATA[][] = new dataMHB();

$DATA[1][3]->M =30;

$DATA[1][3]->H =15;

$DATA[1][3]->B =244;

$DATA[1][3]->gray =40;

// ==== BACA RGB Citra =====

$im = imagecreatefromjpeg($dewi);

$imred = imagecreatefromjpeg($dewi);

$imred1 = imagecreatefromjpeg($dewi);

//$imgreen = imagecreatefromjpeg($dewi);

(23)

$imgray = imagecreatefromjpeg($dewi);

$x=0;

$dtMHB[][] = new dataMHB();

for($x==0;$x<$lebar-1;$x++)

{

$im = imagecreatefromjpeg($dewi);

$y=0;

for($y==0;$y<$tinggi-1;$y++)

{

//echo "y=". $y . ", x=" . $x . "</BR>";

//Ambil Data Citra

$mhb = imagecolorat($im, $x, $y);

//Get RGB disimpan dalam variabel biasa (JADUL)

//$r = (int)(($rgb >> 16) & 0xFF); //mode JADUL

$red[$x][$y] = (int)(($mhb >> 13) & 0xFF);

$green[$x][$y] = (int)(($mhb >> 8) & 0xFF);

$blue[$x][$y] = (int)($mhb & 0xFF);

//$gray[$x][$y]= (int)(($m+$h+$b)/3);

//Simpan data RGB to Array berbasis Structure

$dtMHB[$x][$y]->M= (int)(($mhb >> 13) & 0xFF);

$dtMHB[$x][$y]->H= (int)(($mhb >> 8) & 0xFF);

$dtMHB[$x][$y]->B= (int)($mhb & 0xFF);

$gray[$x][$y]= (int)(($m+$h+$b)/3);

//$dtMHB[$x][$y]->gray=(int)(($dtMHB[$x][$y]->M+$dtMHB[$x][$y]->H+$dtMHB[$x][$y]->B)/3);

//$dtMHB[$x][$y]->gray= $dtMHB[$x][$y]->gray+100;

//if($dtMHB[$x][$y]->gray > 255)

//{

(24)

//}

//if($dtMHB[$x][$y]->gray < 0)

//{

//$dtMHB[$x][$y]->gray=0;

//}

//tampilkan data RGB

//echo "Matrik [$x,$y] R=$r, G=$g, B=$b <BR>";

//tulis pixel

$gray = imagecolorallocate($imgray, $dtMHB[$x][$y]->M,$dtMHB[$x][$y]->gray, $dtMHB[$x][$y]->gray);

$merah1 = imagecolorallocate($imred1, $dtMHB[$x][$y]->M, 0, 0);

$merah = imagecolorallocate($imred, $dtMHB[$x][$y]->M, 80, 50);

//$hijau = imagecolorallocate($imgreen, 0, $dtMHB[$x][$y]->H, 0);

//$biru = imagecolorallocate($imblue, 0, 0, $dtMHB[$x][$y]->B);

// set $from to $to if hex matches.

imagesetpixel($imred1, $x, $y, $merah1);

imagesetpixel($imred, $x, $y, $merah);

// imagesetpixel($imgreen, $x, $y, $hijau);

//imagesetpixel($imblue, $x, $y, $biru);

//imagesetpixel($im2, $x, $y, $gray);

imagesetpixel($imgray, $x, $y, $gray);

}

}

echo"<br>";

echo"<br>";

imagepng($imred1, "merah1.jpg");

imagedestroy($imred1);

echo "Sebelum Proses Brightness";

(25)

print("<P>");

print("<IMG SRC=\"$dewi\">");

print("<P>");

//Simpan Citra Gray

imagepng($imred, "merah.jpg");

imagedestroy($imred);

$dewi="merah.jpg";

print("<P>");

print("<IMG SRC=\"$dewi\">");

print("<P>");

echo "Hasil Proses Brightness";

//Simpan Citra Gray

// imagepng($imgray, "gray.jpg");

// imagedestroy($imgray);

//$dewi="gray.jpg";

//print("<P>");

print("<IMG SRC=\"$dewi\">");

print("<P>");

echo "Hasil Proses Brightness";

?>

(26)
(27)

SKRIP GRAY

<?php

error_reporting(0);

//============ PENGOLAHAN CITRA 24 BIT =========

/*

Berikut ini adalah contoh coding mengkases citra dan menyimpannya kedalam array berbasi structure/variabel-buatan..

*/

$dewi="asli.jpg";

$hasil = getimagesize($dewi);

if(! $hasil)

{

die("File $citra tidak dapat dibuka");

}

else

{

//tampilkan informasi data citra

//print("<IMG SRC=\"$dewi\">");

//print("<P>");

//print("Lebar Citra = $hasil[0] <BR>\n");

//print("Tinggi Citra = $hasil[1] <BR>\n");

//print("Tipe Citra = $hasil[2] <BR>\n");

//print("String Citra = $hasil[3] <BR>\n");

}

$gb=imagecreatefromJPEG($dewi);

//==== Baca Citra Ukuran Tinggi Lebar ===

list($lebar, $tinggi, $type, $attr) = getimagesize($dewi);

//Tampilkan tinggi lebar citra

(28)

echo "<BR>";

echo "Image height " .$tinggi;

echo "<BR>";

echo "Image type " .$type;

echo "<BR>";

echo "Attribute " .$attr;

//fungsi membaca citra *.PNG

$im = imagecreatefrompng("asli.jpg");

$mhb = imagecolorat($im, 10, 15);

$m = ($mhb >> 16) & 0xFF;

$h = ($mhb >> 8) & 0xFF;

$b = $mhb & 0xFF;

var_dump($m, $h, $b);

//syntax membaca citra *.JPG

$im = imagecreatefromjpeg($dewi);

$mhb = imagecolorat($im, 10, 15);

$m = ($mhb >> 16) & 0xFF;

$h = ($mhb >> 8) & 0xFF;

$b = $mhb & 0xFF;

//var_dump($r, $g, $b);

//=== Variabel Buatan/Struc/Structure ====

class dataMHB

{

public $M; //untuk red

public $H; //untuk green

public $B; //untuk blue

public $gray; //untuk gray

(29)

}

//========================================

//contoh mengakses variabel biasa berbasis struct

$data = new dataMHB();

$data->M =30;

$data->H =15;

$data->B =244;

$data->gray =40;

//CONTOH mengakses variabel Array D1 berbasis struct

$dt[] = new dataMHB();

$dt[1]->M =30;

$dt[1]->H=15;

$dt[1]->B =244;

echo $dt[1]->gray =40;

//CONTOH mengakses variabel Array D2 berbasis struct

$DATA[][] = new dataMHB();

$DATA[1][3]->M =30;

$DATA[1][3]->H =15;

$DATA[1][3]->B =244;

$DATA[1][3]->gray =40;

// ==== BACA RGB Citra =====

$im = imagecreatefromjpeg($dewi);

$imred = imagecreatefromjpeg($dewi);

$imred1 = imagecreatefromjpeg($dewi);

//$imgreen = imagecreatefromjpeg($dewi);

//$imblue = imagecreatefromjpeg($dewi);

(30)

$x=0;

$dtMHB[][] = new dataMHB();

for($x==0;$x<$lebar-1;$x++)

{

$im = imagecreatefromjpeg($dewi);

$y=0;

for($y==0;$y<$tinggi-1;$y++)

{

//echo "y=". $y . ", x=" . $x . "</BR>";

//Ambil Data Citra

$mhb = imagecolorat($im, $x, $y);

//Get RGB disimpan dalam variabel biasa (JADUL)

//$r = (int)(($rgb >> 16) & 0xFF); //mode JADUL

$red[$x][$y] = (int)(($mhb >> 13) & 0xFF);

$green[$x][$y] = (int)(($mhb >> 8) & 0xFF);

$blue[$x][$y] = (int)($mhb & 0xFF);

//$gray[$x][$y]= (int)(($m+$h+$b)/3);

//Simpan data RGB to Array berbasis Structure

$dtMHB[$x][$y]->M= (int)(($mhb >> 13) & 0xFF);

$dtMHB[$x][$y]->H= (int)(($mhb >> 8) & 0xFF);

$dtMHB[$x][$y]->B= (int)($mhb & 0xFF);

//$gray[$x][$y]= (int)(($m+$h+$b)/3);

$dtMHB[$x][$y]->gray=(int)(($dtMHB[$x][$y]->M+$dtMHB[$x][$y]->H+ $dtMHB[$x][$y]->B)/3);

$dtMHB[$x][$y]->gray= $dtMHB[$x][$y]->gray+100;

if($dtMHB[$x][$y]->gray > 255)

{

(31)

}

if($dtMHB[$x][$y]->gray < 0)

{

$dtMHB[$x][$y]->gray=0;

}

//tampilkan data RGB

//echo "Matrik [$x,$y] R=$r, G=$g, B=$b <BR>";

//tulis pixel

$gray = imagecolorallocate($imgray, $dtMHB[$x][$y]->M,$dtMHB[$x][$y]->gray, $dtMHB[$x][$y]->gray);

$merah1 = imagecolorallocate($imred1, $dtMHB[$x][$y]->M, 0, 0);

$merah = imagecolorallocate($imred, $dtMHB[$x][$y]->M, 80, 50);

//$hijau = imagecolorallocate($imgreen, 0, $dtMHB[$x][$y]->H, 0);

//$biru = imagecolorallocate($imblue, 0, 0, $dtMHB[$x][$y]->B);

// set $from to $to if hex matches.

imagesetpixel($imred1, $x, $y, $merah1);

imagesetpixel($imred, $x, $y, $merah);

// imagesetpixel($imgreen, $x, $y, $hijau);

//imagesetpixel($imblue, $x, $y, $biru);

imagesetpixel($im2, $x, $y, $gray);

imagesetpixel($imgray, $x, $y, $gray);

}

}

echo"<br>";

echo"<br>";

imagepng($imgray, "gray.jpg");

imagedestroy($imgray);

echo "Sebelum Proses Brightness";

(32)

print("<P>");

print("<IMG SRC=\"$dewi\">");

print("<P>");

//Simpan Citra Gray

imagepng($imred, "merah.jpg");

imagedestroy($imred);

$dewi="merah.jpg";

print("<P>");

print("<IMG SRC=\"$dewi\">");

print("<P>");

echo "Hasil Proses Brightness";

//Simpan Citra Gray

// imagepng($imgray, "gray.jpg");

// imagedestroy($imgray);

//$dewi="gray.jpg";

//print("<P>");

print("<IMG SRC=\"$dewi\">");

print("<P>");

echo "Hasil Proses Brightness";

?>

(33)

6.

SKRIP CONTRAS

<?php

error_reporting(0);

//============ PENGOLAHAN CITRA 24 BIT =========

/*

Berikut ini adalah contoh coding mengkases citra dan menyimpannya kedalam array berbasi structure/variabel-buatan..

(34)

$dewi="asli.jpg";

$hasil = getimagesize($dewi);

if(! $hasil)

{

die("File $citra tidak dapat dibuka");

}

else

{

//tampilkan informasi data citra

//print("<IMG SRC=\"$dewi\">");

//print("<P>");

//print("Lebar Citra = $hasil[0] <BR>\n");

//print("Tinggi Citra = $hasil[1] <BR>\n");

//print("Tipe Citra = $hasil[2] <BR>\n");

//print("String Citra = $hasil[3] <BR>\n");

}

$gb=imagecreatefromJPEG($dewi);

//==== Baca Citra Ukuran Tinggi Lebar ===

list($lebar, $tinggi, $type, $attr) = getimagesize($dewi);

//Tampilkan tinggi lebar citra

echo "Image width " .$lebar;

echo "<BR>";

echo "Image height " .$tinggi;

echo "<BR>";

echo "Image type " .$type;

echo "<BR>";

echo "Attribute " .$attr;

(35)

$im = imagecreatefrompng("asli.jpg");

$mhb = imagecolorat($im, 10, 15);

$m = ($mhb >> 16) & 0xFF;

$h = ($mhb >> 8) & 0xFF;

$b = $mhb & 0xFF;

var_dump($m, $h, $b);

//syntax membaca citra *.JPG

$im = imagecreatefromjpeg($dewi);

$mhb = imagecolorat($im, 10, 15);

$m = ($mhb >> 16) & 0xFF;

$h = ($mhb >> 8) & 0xFF;

$b = $mhb & 0xFF;

//var_dump($r, $g, $b);

//=== Variabel Buatan/Struc/Structure ====

class dataMHB

{

public $M; //untuk red

public $H; //untuk green

public $B; //untuk blue

public $gray; //untuk gray

public $teks; //misalnya

}

//========================================

//contoh mengakses variabel biasa berbasis struct

$data = new dataMHB();

$data->M =30;

$data->H =15;

(36)

$data->gray =40;

//CONTOH mengakses variabel Array D1 berbasis struct

$dt[] = new dataMHB();

$dt[1]->M =30;

$dt[1]->H=15;

$dt[1]->B =244;

echo $dt[1]->gray =40;

//CONTOH mengakses variabel Array D2 berbasis struct

$DATA[][] = new dataMHB();

$DATA[1][3]->M =30;

$DATA[1][3]->H =15;

$DATA[1][3]->B =244;

$DATA[1][3]->gray =40;

// ==== BACA RGB Citra =====

$im = imagecreatefromjpeg($dewi);

$imred = imagecreatefromjpeg($dewi);

$imred1 = imagecreatefromjpeg($dewi);

//$imgreen = imagecreatefromjpeg($dewi);

//$imblue = imagecreatefromjpeg($dewi);

$imgray = imagecreatefromjpeg($dewi);

$x=0;

$dtMHB[][] = new dataMHB();

for($x==0;$x<$lebar-1;$x++)

{

$im = imagecreatefromjpeg($dewi);

$y=0;

for($y==0;$y<$tinggi-1;$y++)

(37)

//echo "y=". $y . ", x=" . $x . "</BR>";

//Ambil Data Citra

$mhb = imagecolorat($im, $x, $y);

//Get RGB disimpan dalam variabel biasa (JADUL)

//$r = (int)(($rgb >> 16) & 0xFF); //mode JADUL

$red[$x][$y] = (int)(($mhb >> 13) & 0xFF);

$green[$x][$y] = (int)(($mhb >> 8) & 0xFF);

$blue[$x][$y] = (int)($mhb & 0xFF);

//$gray[$x][$y]= (int)(($m+$h+$b)/3);

//Simpan data RGB to Array berbasis Structure

$dtMHB[$x][$y]->M= (int)(($mhb >> 13) & 0xFF);

$dtMHB[$x][$y]->H= (int)(($mhb >> 8) & 0xFF);

$dtMHB[$x][$y]->B= (int)($mhb & 0xFF);

$gray[$x][$y]= (int)((2*40-50)+50);

//$dtMHB[$x][$y]->gray=(int)(($dtMHB[$x][$y]->M+$dtMHB[$x][$y]->H+$dtMHB[$x][$y]->B)/3);

//$dtMHB[$x][$y]->gray= $dtMHB[$x][$y]->gray+100;

if($dtMHB[$x][$y]->gray > 255)

{

$dtMHB[$x][$y]->gray=255;

}

if($dtMHB[$x][$y]->gray < 0)

{

$dtMHB[$x][$y]->gray=0;

}

//tampilkan data RGB

//echo "Matrik [$x,$y] R=$r, G=$g, B=$b <BR>";

(38)

$gray = imagecolorallocate($imgray, $dtMHB[$x][$y]->M,$dtMHB[$x][$y]->gray, $dtMHB[$x][$y]->gray);

$merah1 = imagecolorallocate($imred1, $dtMHB[$x][$y]->M, 0, 0);

$merah = imagecolorallocate($imred, $dtMHB[$x][$y]->M, 80, 50);

//$hijau = imagecolorallocate($imgreen, 0, $dtMHB[$x][$y]->H, 0);

//$biru = imagecolorallocate($imblue, 0, 0, $dtMHB[$x][$y]->B);

// set $from to $to if hex matches.

imagesetpixel($imred1, $x, $y, $merah1);

imagesetpixel($imred, $x, $y, $merah);

// imagesetpixel($imgreen, $x, $y, $hijau);

//imagesetpixel($imblue, $x, $y, $biru);

imagesetpixel($im2, $x, $y, $gray);

imagesetpixel($imgray, $x, $y, $gray);

}

}

echo"<br>";

echo"<br>";

imagepng($imgray, "gray.jpg");

imagedestroy($imgray);

echo "Sebelum Proses Brightness";

$dewi="gray.jpg";

print("<P>");

print("<IMG SRC=\"$dewi\">");

print("<P>");

//Simpan Citra Gray

imagepng($imred, "merah.jpg");

imagedestroy($imred);

$dewi="merah.jpg";

(39)

print("<IMG SRC=\"$dewi\">");

print("<P>");

echo "Hasil Proses Brightness";

//Simpan Citra Gray

// imagepng($imgray, "gray.jpg");

// imagedestroy($imgray);

//$dewi="gray.jpg";

//print("<P>");

print("<IMG SRC=\"$dewi\">");

print("<P>");

echo "Hasil Proses Brightness";

?>

(40)

7.

SKRIP INDEX

<html>

<head>

<title>Dewi Yuliana Setyowati</title>

</head>

<body background=bunga.jpg>

<marquee><font size=4 face=tahoma color=green>SELAMAT DATANG</font>

<hr size=1 width=150 align=left></marquee>

<div align="center"><font size=7 face=verdana color=#FF00CC><b>PENCITRAAN DIGITAL</b></font> </div>

<hr size=5 align=center noshade>

<hr>

<p align="center">Judul Tugas : </p>

<p align="center">Citra_brightness_structure</p>

<p align="left">Silahkan klik menu dibawah ini untuk membandingkan hasil dari proses Brightness </p>

<p align="left">|<a href=index.php>ASLI </a>|<a href=kedua.php>MERAH </a>|<a href=ketiga.php>HIJAU </a>|<a href=keempat.php>BIRU</a>|

<div align="left"><font size=4 face=tahoma color=green >Ini gambar asli</font></div>

<hr><p align="center">

<body>

<?php

(41)

?>

<hr size=5 align=center noshade>

<p align="center">Copyright@Dewi Yuliana .S(111080200200) </p>

</body>

</body>

</html>

HASIL GAMBAR INDEX

PENGERTIAN SKRIP2 PHP

1. Fungsi GetImageSize() disini menghasilkan array pertama yaitu lebar dari file gambar yang

akan diupload dan array kedua adalah tinggi dari gambar yang akan diupload.

2. Imagecreatefromjpeg membuat gambar yang berasal dari sebuah URL ataupun nama sebuah

file

3. Getimagesize yang akan menghasilkan array informasi dari file gambar yang akan kita resize

(yang diset melalui constructor)

4. Imagecreatefromjpeg load gambar dari sumber yang disediakan

5. Imagecolorallocatefungsi untuk menyimpan warna

Referensi

Dokumen terkait

Bentuk diskusi kelompok resmi yang disebut dengan istilah simposium ini sungguh sangat bermanfaat apabila pokok pembicaraan yang sedang didiskusikan itu tidak dapat dijawab dengan

Berdasarkan pada hasil analisis diketahui bahwa entres yang disimpan selama 2 dan 4 hari menggunakan media kertas koran dan serbuk gergaji yang telah dibasahi masih menghasilkan

Secara terinci, matriks aktualisasi telah mencoba menjabarkan masing-masing sila dari Pancasila mulai dari perwujudan dan aktualisasinya, hingga implikasinya dalam penanganan

Hasil pengujian tarik komposit hibrid kenaf/E- glass LDPE menunjukkan bahwa semakin bertambahnya fraksi volume serat E-glass menyebabkan kekuatan komposit semakin

Dalam kedudukannya sebagai pengelola barang, dan dihubungkan dengan amanat pasal 6 ayat (2) Undang-undang nomor 17 tahun 2003, Gubernur juga berwenang mengajukan usul untuk

Saudara dapat memilih Mata Kuliah yang diajukan untuk RPL sesuai dengan kompetensi (Capaian Pembelajaran Mata Kuliah) yang menurut saudara telah diperoleh dari

Memang pada saat ini ada beberapa merger yang dalam proses menuju ke arah kerja sama dengan kita dengan lebih erat namun kami berada dalam kondisi dimana kami belum

Dari keempat penyebab tingkat kerusakan bangunan tersebut, ada dua hal yang bisa diupayakan untuk mengurangi jumlah korban akiba t gempa bumi yaitu meningkatkan