histogram tre

Upload: nurul-aulia-sari

Post on 07-Jul-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/18/2019 Histogram Tre

    1/1

    Public Class Form1  Dim hR(0 To 255) As Integer  Dim hmaxr As Integer = 0  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click  Dim gambar As String = "C:\Users\santri_liar\Desktop\pic.jpg"  Dim bmp As Bitmap = New Bitmap(gambar)

      Dim r, g, b, a, t, t1, y As Integer  Dim c As Color  y = TextBox1.Text

      Dim ht(256) As Integer  For i = 1 To 256  ht(i) = 0  Next

      For i = 0 To PictureBox1.Width - 1  For j = 0 To PictureBox1.Height - 1  c = bmp.GetPixel(i, j)

      r = c.R  g = c.G  b = c.B

      t = (r + g + b) / 3  a = 256 / y  t = a * Int(t / a)  ht(t + 1) = ht(t + 1) + 1  bmp.SetPixel(i, j, Color.FromArgb(t, t, t))

      Next  PictureBox1.Image = bmp  Next

      Dim hH As Integer = PictureBox1.Height 

    Dim xp As Integer  Dim gambar2 As Graphics = PictureBox2.CreateGraphics 

    Dim myPenR As Pen = New Pen(Color.Red) 

    For i = 1 To 256  xp = (4 * (i - 1) + 1) / 2  gambar2.DrawLine(myPenR, xp, hH - ht(i), xp, hH)

      Next

      End Sub

      Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

      End SubEnd Class