1 / 20

Pengolahan Citra Digital

Pengolahan Citra Digital. 3 – Warna dan Operasinya Disusun oleh Teady Matius Surya Mulyana ( teadymatius@yahoo.com / tmulyana@bundamulia.ac.id ) Dari berbagai sumber. RGB. R  Red G  Green B  Blue Setiap byte menunjukan nilai warna yang diwakili tersebut pada suatu pixel. Misal:

debbie
Download Presentation

Pengolahan Citra Digital

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Pengolahan Citra Digital 3 – Warna dan Operasinya Disusun oleh Teady Matius Surya Mulyana (teadymatius@yahoo.com / tmulyana@bundamulia.ac.id ) Dari berbagai sumber

  2. RGB • R  Red • G  Green • B  Blue • Setiap byte menunjukan nilai warna yang diwakili tersebut pada suatu pixel. Misal: • FFFFFF  putih • FF0000  merah • 00FF00  hijau • 0000FF  biru • 000000  hitam • FFFF00  kuning

  3. RGB illumination Sumber gambar: http://art110.wikispaces.com/file/view/RGB_illumination.jpg/34175247/RGB_illumination.jpg Diakses tanggal: 7 Maret 2013

  4. CMYK • C  Cyan • M  Magenta • Y  Yellow • K  derajat kehitaman Sumber gambar: http://3.bp.blogspot.com/-Urth6mtuA04/TiwNCR4HaSI/AAAAAAAAAWs/pPaNHCEBxXg/s1600/cmyk-print1.jpg Diakses tanggal 7 Maret 2013

  5. CMYK Mixing Sumber gambar: http://bpiinc.files.wordpress.com/2011/11/cmyk.jpg Diakses tanggal: 7 Maret 2013

  6. RGB vs CMYK Sumber gambar: http://www.12on14.com/dpi/rgb-cmyk.jpg Diakses tanggal 7 maret 2013

  7. RGB to CMYK • C = 1 – R • M = 1 – G • Y = 1 – B • K = 0 untuk warna bukan hitam • K = 1 untuk warna hitam Sumbergambar: http://i656.photobucket.com/albums/uu289/younis-des/vgn4nq.jpg Diaksestanggal 7 maret 2013

  8. HIS/HSV/HSL • H  Hue • S  Saturation • I  Intensity / V  Value / L  Luminous

  9. Warna pada JAVA • Ditangani oleh method setColor(Color c) yang terdapat pada Class Graphics.

  10. Constructor Class Color • Color(ColorSpace cspace, float[] components, float alpha) • Creates a color in the specified ColorSpace with the color components specified in the float array and the specified alpha. • Color(float r, float g, float b) • Creates an opaque sRGB color with the specified red, green, and blue values in the range (0.0 - 1.0). • Color(float r, float g, float b, float a) • Creates an sRGB color with the specified red, green, blue, and alpha values in the range (0.0 - 1.0). • Color(int rgb) • Creates an opaque sRGB color with the specified combined RGB value consisting of the red component in bits 16-23, the green component in bits 8-15, and the blue component in bits 0-7. • Color(int rgba, boolean hasalpha) • Creates an sRGB color with the specified combined RGBA value consisting of the alpha component in bits 24-31, the red component in bits 16-23, the green component in bits 8-15, and the blue component in bits 0-7. • Color(int r, int g, int b) • Creates an opaque sRGB color with the specified red, green, and blue values in the range (0 - 255). • Color(int r, int g, int b, int a) • Creates an sRGB color with the specified red, green, blue, and alpha values in the range (0 - 255).

  11. Catatan untuk Pemakaian Constructor Class Color • Untuk nilai alpha tidak kita perlukan, jadi gunakan construtor yang alphanya sudah pasti di set 255 untuk yang bertipe integer atau 1 untuk yang bertipe float. • Gunakan Constructor dengan format rgb yang terpisah, agar anda tidak perlu melakukan operasi untuk memisahkan nilai-nilai rgb nya. • Constructor yang disarankan: • Color(float r, float g, float b) • Color(int r, int g, int b)

  12. Memilah RGB pada java • Nilai yang didapat dari pengambilan warna pada suatu pixel adalah suatu nilai integer. • Komposisi warna RGB pada warna adalah alpha|Red|Green|Blue yang masing-masing bernilai 1 byte.

  13. Memperoleh warna B • Untuk mendapatkan nilai B, ambil 1 byte (8 bit) dari belakang, masukkan ke variable penampungnya. • Dapat dilakukan dengan melakukan operasi bitwise operator & dengan nilai 0xff untuk menghilangkan nilai alpha, R dan G nya • Operasi akan menghasilkan nilai integer untuk komponen warna B • Contoh: • b=warna & 0xff; • Jika warna bernilai ff352A37 = 1111 1111 0011 0101 0010 1010 0011 0111 • Maka operasi bitwise & 0xff terhadap variabel warna akan menghasilkan nilai 0000037 • 1111 1111 0011 0101 0010 1010 0011 0111 • 0000 0000 0000 0000 0000 0000 1111 1111 • _____________________________________ & • 0000 0000 0000 0000 0000 0000 0011 0111 = $00000037 = 55

  14. Memperoleh nilai G • Ambil byte ke 2 dari belakang (lsb) masukkan ke variable penampungnya. • Untuk melakukan hal tersebut, lakukan operasi shift kanan sebanyak 8 kali, sehingga akan didapatkan byte ke 2-lsb tersebut menjadi byte ke 1-lsb. Kemudian lakukan operasi bitwise & dengna 0xff untuk menghilangkan nilai alpha dan R nya • Contoh • g=(warna >> 8) & 0xff; • Jika warna bernilai ff352A37 = 1111 1111 0011 0101 0010 1010 0011 0111 • Maka operasi bitwise (warna >> 8) & 0xff terhadap variabel warna akan menghasilkan nilai 000002A • 0000 0000 1111 1111 0011 0101 0010 1010 • 0000 0000 0000 0000 0000 0000 1111 1111 • _____________________________________ & • 0000 0000 0000 0000 0000 0000 0010 1010 = $0000002A = 41

  15. Memperoleh nilai R • Ambil byte ke 3 dari belakang (lsb) masukkan ke variable penampungnya. • Untuk melakukan hal tersebut, lakukan operasi shift kanan sebanyak 16 kali, sehingga akan didapatkan byte ke 3-lsb tersebut menjadi byte ke 1-lsb. Kemudian lakukan operasi bitwise & dengan 0xff untuk menghilangkan nilai alpha • Contoh • g=(warna >> 8) & 0xff; • Jika warna bernilai ff352A37 = 1111 1111 0011 0101 0010 1010 0011 0111 • Maka operasi bitwise (warna >> 16) & 0xff terhadap variabel warna akan menghasilkan nilai 000002A • 0000 0000 0000 0000 1111 1111 0011 0101 • 0000 0000 0000 0000 0000 0000 1111 1111 • _____________________________________ & • 0000 0000 0000 0000 0000 0000 0011 0101 = $00000035 = 53

  16. Operasi-operasi warna pada RGB • Negative: 255-C • Darken: C/p atau C-p • Brighten: C*p atau C+p • Greyscale: (R+G+B) / 3 • Remove Channel: Pengaturan satu channel atau lebih menjadi 0 • Swap Channel: Menukar nilai-nilai dari dua channel

  17. Negative • Negative = 255-C  C adalah nilai masing-masing channel warna yang diwakili • Mengubah warna menjadi kebalikannya

  18. Grayscale • Grayscale = (R+G+B) / 3 • Untuk menghasilkan warna grayscale, dapat dilakukan dengan menjumlah semua nilai R, G dan B serta membagi hasilnya dengan 3

  19. Darken • Darken = C/p atau Darken = C-p • Membagi atau mengurangi warna dengan suatu nilai p agar terlihat lebih gelap

  20. Brighten • Brighten = C*p atau Brighten = C+p • Mengalikan warna dengan konstan ataunpun menambahkan warna dengan suatu nilai p agar terlihat lebih terang

More Related