CONTRAST SCRETCHING dan IMAGE NEGATIVE



Carilah hasil akhir dari proses CONTRAST SCRETCHING dan IMAGE NEGATIVE dari data dibawah





1.  CONTRAST SCRETCHING 











Persamaan garisnya :







diketahui : (r1,s1) dan (r2,s2)







sehingga:




























Untuk S-I, dimana diketahui titik 1 (0,0) titik 2 (0.1,0.3)
sehingga:





































S = 3 r untuk 0 ≤ r ≤ 0.1

 
Untuk S-II, dimana diketahui titik 1 (0.1,0.3) titik 2 (0.4,0.3)
sehingga:






















S  = r  + 0.3 untuk 0.3≤ r ≤0.4


Untuk S-II, dimana diketahui titik 1 (0.4,0.3) titik 2 (0.8,0.6)
sehingga:























Graylevel yang diketahui adalah :















1.  200 --> r = 200/255
= 0.78431
S-IV

2. 10 --> r = 10/255
= 0.03922
S-I

3. 50 --> r = 50/255
= 0.19608
S-II

4. 70 --> r = 70/255
= 0.27451
S-II

5. 125 --> r = 125/255
= 0.4902
S-III

6. 150--> r = 150/255
= 0.58824
S-III





















Kemudian masukkan r di atas kedalam persamaan garisnya :























1 S    = 2r - 1








2*0.784314-1 * 255






1.5688-1  * 255







144,993








145


























2 S = 3 r








3*0.039216  * 255







29,988








30
















3 S  = r  + 0.3








0.196078 + 0.3 * 255






126.506








127
















4 S  = r  + 0.3








0.027451 + 0.3 *255






146.498








146
















5 S   = (3/4) r -9/20







0.75 * 0.5882 - 0.45 * 255






-2.2568








-2
















6 S   = (3/4) r -9/20







0.75*0.490196 - 0.45 * 255






-21.018








-21
















Tabel hasil akhirnya adalah :























2.  IMAGE NEGATIVE




















Model Image Negative :




S = - r + L - 1





S = L - 1 - r







L adalah Max.Graylevel












Jawab  :














Dari citra input diperoleh L = 200, sehingga persamaan garisnya adalah :

S  =  200  - 255  - r





S  = -55  - r













Maka Graylevel Outputnya  :




200 S = -55-200  = - 255



150 S = -55-150  = - 405



125 S = -55-125  = - 180



70 S = -55-70    = - 125



50 S = -55-50    = - 105



10 S = -55-10    = -65




















Maka tabel Hasil Akhirnya  :



 


Pengolahan Citra Digital

                                                                              Tugas 1

                                                                        Gambar N4


                                                                      Gambar ND



                                                                        Gambar N8

MID GRAFIKA KOMPUTER


MID
GRAFIKA KOMPUTER

Soal :
1. Rotasi
      A(150,100)
      B(100,250)
     C(200,250)  terhadap titik X (200,200) dengan sudut putar 45

2. Translasi terhadap  T(50 & 100) dari kedua nomor tersebut :
a. Buat lisning programnya !
b. Tentukan titik hasil rotasi A translasinya



JAWAB
Lisning soal A

ROTASI

package rotasi;

import java.awt.*;
import java.awt.event.*;
public class Rotasi extends Frame implements ActionListener{
int x = 200;
int y = 200;
public static void main(String[] args) {
Frame frame = new Rotasi();
frame.setSize(200,200);
frame.setVisible(true);
}
public Rotasi() {
setTitle("AWT Demo");
// create menu
MenuBar mb = new MenuBar();
setMenuBar(mb);
Menu menu = new Menu("File");
mb.add(menu);
MenuItem mi = new MenuItem("Exit");
mi.addActionListener(this);
menu.add(mi);
// end program when window is closed
WindowListener l = new WindowAdapter()  {
public void windowClosing(WindowEvent ev) {
System.exit(0);
}
};
this.addWindowListener(l);
// mouse event handler
MouseListener mouseListener = new MouseAdapter() {
public void mouseClicked(MouseEvent ev) {
x = ev.getX();
y = ev.getY();
repaint();
}
};
addMouseListener(mouseListener);
}

public void paint(Graphics g) {
int xasalA = 150; int yasalA = 100;
int xasalB = 100; int yasalB = 250;
int xasalC = 200; int yasalC = 250;


int sudut = 45;

g.setColor(Color.blue);
g.drawLine(xasalA,yasalA, xasalB,yasalB);
g.drawLine(xasalB,yasalB,xasalC,yasalC);

long xA = Math.round(x+(xasalA-x)*Math.cos(sudut)-(yasalA-y)*Math.sin(sudut));
long yA = Math.round(x+(xasalA-x)*Math.sin(sudut)-(yasalA-y)*Math.cos(sudut));
long xB = Math.round(x+(xasalB-x)*Math.cos(sudut)-(yasalB-y)*Math.sin(sudut));
long yB = Math.round(x+(xasalB-x)*Math.sin(sudut)-(yasalB-y)*Math.cos(sudut));
long xC = Math.round(x+(xasalC-x)*Math.cos(sudut)-(yasalC-y)*Math.sin(sudut));
long yC = Math.round(x+(xasalC-x)*Math.sin(sudut)-(yasalC-y)*Math.cos(sudut));

int xA1 = (int)xA; int yA1 = (int)yA;
int xB1 = (int)xB; int yB1 = (int)yB;
int xC1 = (int)xC; int yC1 = (int)yC;

g.drawLine(xA1,yA1, xB1,yB1);
g.drawLine(xB1,yB1, xC1,yC1);



}
public void actionPerformed(ActionEvent ev) {
String command = ev.getActionCommand();
if ("Exit".equals(command)) {
System.exit(0);
}
}
}


                                                                    Hasil Outputnya










TRANSLASI :

package translasi_roswitha;

import java.awt.*;
import java.awt.event.*;
public class Translasi_roswitha extends Frame implements ActionListener{
int x = 50;
int y = 100;
public static void main(String[] args) {
Frame frame = new Translasi_roswitha();
frame.setSize(640, 480);
frame.setVisible(true);
}
public Translasi_roswitha() {
setTitle("AWT Demo");
// create menu
MenuBar mb = new MenuBar();
setMenuBar(mb);
Menu menu = new Menu("File");
mb.add(menu);
MenuItem mi = new MenuItem("Exit");
mi.addActionListener(this);
menu.add(mi);
// end program when window is closed
WindowListener l = new WindowAdapter()  {
public void windowClosing(WindowEvent ev) {
System.exit(0);
}
};
this.addWindowListener(l);
// mouse event handler
MouseListener mouseListener = new MouseAdapter() {
public void mouseClicked(MouseEvent ev) {
int x = 50;
int y = 100;
repaint();
}
};
addMouseListener(mouseListener);
}

public void paint(Graphics g) {

g.drawLine(30, 30, 200, 300);
g.drawLine(30+x, 30+y, 200+x, 300+y);



}
public void actionPerformed(ActionEvent ev) {
String command = ev.getActionCommand();
if ("Exit".equals(command)) {
System.exit(0);
}
}
}
                                                                               Hasil Outputnya





Algoritma pembentukan garis DDA

Algoritma pembentukan garis DDA :

1. Tentukan dua titik yang akan dihubungkan dalam pembentukan garis.
2. Tentukan salah satu titik sebagai awal(x0,y0) dan titik akhir(x1,y1).
3. Hitung dx=x1¬x0, dan dy= y1¬y0.
4. Tentukan langkah, yaitu dengan cara jarak maksimum jumlah penambahan nilai x maupun nilai y, dengan caara :
Bila nilai absolut dari dx lebih besar dari absolut dy, maka langkah= absolut dari dx.
Bila tidak maka langkah= absolut dari dy
5. Hitung penambahan koordinat pixel yaitu x_increment=dx/langkah, dan y_increment=dy/langkah.
6. Koordinat selanjutnya (x+x_increment, y+y_increment).
7. Posisi pixel pada layar ditentukan dengan pembulatan nilai koordinat tersebut.
8. Ulangi nomor 6 dan 7 untuk menentukan posisi pixel selanjutnya,sampai x= x1 dan y= y1

Contoh Source Code nya :
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package roswitha;

import java.awt.Graphics;

/**
 *
 * @author JC
 */
public class roswitha {
  
    public void Garisku (Graphics g, int x0, int y0, int x1, int y1){
        int dx,dy,steps;
        int x_tambah,y_tambah,x,y;
                            
  dx= x1-x0;
  dy= y1-y0;     
               
  if (Math.abs(dx) > Math.abs(dy)){
   steps = Math.abs(dx);
  }
  else{
   steps = Math.abs(dy);
  }
  x_tambah = dx / steps;
  y_tambah = dy / steps;
                x=x0;
                y=y0;
                       
                g.fillRect(x, y, 1, 1);
  for (int k=10; k< steps ;k++){
   x += x_tambah;
   y += y_tambah;
  
                        g.fillRect(x, y, 1, 1);
  }             
       
    }
   
}

Contoh Source Code untuk memanggil Class Garis yang bagian pertama yang sudah kita buat
Source Code nya :
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package roswitha;

import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 *
 * @author JC
 */
public class tampilgaris extends JPanel{
    @Override
    public void paintComponent(Graphics g){
       
        roswitha baru = new roswitha();
        g.setColor(Color.RED);
        baru.Garisku(g, 200, 300, 400, 300);
        baru.Garisku(g, 200, 160, 400, 160);
            }
   
    public static void main(String[] args) {
        roswitha baru = new roswitha();
        JFrame frame = new JFrame("Roswitha Gambar ");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.add(new tampilgaris());
        frame.setSize(600, 600);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
              
    }
}
                                                                        HASILNYA :

TUGAS RANGKAIAN DIGITAL 2

                                                     NAMA : Roswitha M Abuk
                                                     KELAS : Extensen (semester 5)
                                                     TUGAS : Rangkaian Digital





CARA BUAT WAJAH ORANG MENGGUNAKAN JAVA

Cara buat program wajah orang menggunakan java caranya seperti di bawah ini

package Roswitha;



import java.awt.*;

import java.awt.event.*;

public class Tugas_roswitha extends Frame implements ActionListener{

    int x = 100;

    int y = 100;

public static void main(String[] args) {

    Frame frame = new Tugas_roswitha();

    frame.setSize(640, 480);

    frame.setVisible(true);

}

public Tugas_roswitha() {

setTitle("Tugas_roswitha");

// create menu

    MenuBar mb = new MenuBar();

    setMenuBar(mb);

    Menu menu = new Menu("File");

    mb.add(menu);

    MenuItem mi = new MenuItem("Exit");

    mi.addActionListener(this);

    menu.add(mi);

// end program when window is closed

    WindowListener l = new WindowAdapter()  {

    public void windowClosing(WindowEvent ev) {

    System.exit(0);

    }

    };

this.addWindowListener(l);

// mouse event handler

MouseListener mouseListener = new MouseAdapter() {

public void mouseClicked(MouseEvent ev) {

    x = ev.getX();

    y = ev.getY();

    repaint();

}

};

addMouseListener(mouseListener);

}



public void paint(Graphics g) {

setBackground (Color.PINK);



        //kepala

g.setColor(Color.RED);

g.drawOval(320,240,  200, 200);

// mata

g.setColor(Color.black);

g.fillOval(360, 310, 50, 20);

g.fillOval(440, 310, 50, 20);



// mulut

g.setColor(Color.black);

g.drawArc(380, 360, 90, 50, 180, 180);

g.drawArc(380, 366, 90, 50, 180, 180);

//alis mata

g.setColor(Color.RED);

g.drawArc(360, 290, 50, 20, -180, -180);

g.drawArc(440, 290, 50, 20, -180, -180);



// bola mata

g.setColor(Color.white);

g.fillOval(379, 321, 10, 10);

g.fillOval(457, 321, 10, 10);

//hidung

g.setColor(Color.GREEN);

g.fillOval(410, 350, 30, 30);

//telinga

g.setColor(Color.YELLOW);

g.fillOval(300, 310, 20, 60);

g.fillOval(520, 310, 20, 60);



}

public void actionPerformed(ActionEvent ev) {

  

String command = ev.getActionCommand();

if ("Exit".equals(command)) {

System.exit(0);

}

}

}

                                                                         Hasilnya :



THIS IS FEATURED POST 1 TITLE

THIS IS FEATURED POST 1 TITLE

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam

Quas molestias excepturi
THIS IS FEATURED POST 2 TITLE

THIS IS FEATURED POST 2 TITLE

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam

Impedit quo minus id
THIS IS FEATURED POST 3 TITLE

THIS IS FEATURED POST 3 TITLE

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam

Voluptates repudiandae kon
THIS IS FEATURED POST 4 TITLE

THIS IS FEATURED POST 4 TITLE

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam

Mauris euismod rhoncus tortor