1 / 8

Pengantar Image Processing - Pendahuluan -

14 Januari 2011. Pengantar Image Processing - Pendahuluan -. Dr. Anto Satriyo Nugroho. Center for Information & Communication Technology, Agency for the Assessment & Application of Technology (PTIK-BPPT) Email: asnugroho@gmail.com URL: http://asnugroho.net. Persiapan Praktikum.

dava
Download Presentation

Pengantar Image Processing - Pendahuluan -

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. 14 Januari 2011 Pengantar Image Processing- Pendahuluan - Dr. Anto Satriyo Nugroho Center for Information & Communication Technology, Agency for the Assessment & Application of Technology (PTIK-BPPT) Email: asnugroho@gmail.com URL: http://asnugroho.net

  2. Persiapan Praktikum • OS: Linux Ubuntu • Editor: vi, emacs, gedit • C Compiler: gcc • imagemagick • display • convert • xgraph

  3. Portable Gray Map • Isi sebuah PGM file adalah sbb. • A "magic number" for identifying the file type. A pgm image's magic number is the two characters "P5". • Whitespace (blanks, TABs, CRs, LFs). • A width, formatted as ASCII characters in decimal. • Whitespace. • A height, again in ASCII decimal. • Whitespace. • The maximum gray value (Maxval), again in ASCII decimal. Must be less than 65536, and more than zero. • A single whitespace character (usually a newline). • A raster of Height rows, in order from top to bottom. Each row consistsof Width gray values, in order from left to right. Each gray value is anumber from 0 through Maxval, with 0 being black and Maxval beingwhite. Each gray value is represented in pure binary by either 1 or 2 bytes. If the Maxval is less than 256, it is 1 byte. Otherwise, it is 2 bytes.The most significant byte is first. http://netpbm.sourceforge.net/doc/pgm.html

  4. Contoh: PGM file • Sebuah citra memiliki ukuran 4 kolom x 3 baris • Header (area yang berwarna hijau): terdiri dari 3 baris yang tertulis dalam plain text ASCII. Masing-masing adalah magick number (P5), lebar tinggi, dan nilai maksimum intensitas • Raster (area yang berwarna kuning): berisi data nilai intensitas masing-masing pixel dalam format BINARY. Dimulai dari pixel paling kiri atas menuju ke kanan bawah. “0” adalah hitam, sedangkan “255” adalah putih. P5 4 3 255 0 0 255 0 255 255 0 128 0 0 255 0

  5. Contoh membuat sebuah citra #include <stdio.h> #include <stdlib.h> main() { FILE *fp; int height=3, width=4; unsigned char putih=255, hitam=0, abu=128; fp=fopen(“contoh-1.pgm”,”w”); fprintf(fp,”P5\n%d %d\n255\n“,width,height); fwrite(&hitam,sizeof(unsigned char),1,fp); fwrite(&hitam,sizeof(unsigned char),1,fp); fwrite(&putih,sizeof(unsigned char),1,fp); fwrite(&hitam,sizeof(unsigned char),1,fp); fwrite(&putih,sizeof(unsigned char),1,fp); fwrite(&putih,sizeof(unsigned char),1,fp); fwrite(&hitam,sizeof(unsigned char),1,fp); fwrite(&abu,sizeof(unsigned char),1,fp); fwrite(&hitam,sizeof(unsigned char),1,fp); fwrite(&hitam,sizeof(unsigned char),1,fp); fwrite(&putih,sizeof(unsigned char),1,fp); fwrite(&hitam,sizeof(unsigned char),1,fp); fclose(fp); }

  6. Bagaimana membaca sebuah citra ? #include <stdio.h> #include <stdlib.h> main() { FILE *fp; int i,j, height=3, width=4; char line[100]; unsigned char pixel_value; fp=fopen(“contoh-1.pgm”,”r”); fgets(line,100,fp); fgets(line,100,fp); fgets(line,100,fp); for(j=0;j<height;j++) for(i=0;i<width;i++) { fread(&pixel_value,sizeof(unsigned char),1,fp); printf(“baris ke %d kolom ke %d nilai pixel=%d\n”,j,i,pixel_value); } fclose(fp); }

  7. Latihan-1 Buatlah program untuk menampilkan citra: radius 25 tinggi 75 Lebar 100

  8. Latihan-2 Buatlah program untuk menampilkan nilai tiap pixel pada citra berikut (ukuran citra: 512x512)

More Related