Академический Документы
Профессиональный Документы
Культура Документы
Dim histogramValues(256)
Dim histogramValuesB(256)
Private Sub HScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As Sys
tem.Windows.Forms.ScrollEventArgs) Handles HScrollBar1.Scroll
TextBox1.Text = HScrollBar1.Value
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.E
ventArgs) Handles Button1.Click
Dim nilaikontras As Integer = HScrollBar1.Value
Dim i, j As Integer
Dim gambar As New Bitmap(PictureBox1.Image)
PictureBox2.Image = gambar
Dim gambar2 As New Bitmap(PictureBox1.Image)
PictureBox1.Image = gambar2
Dim r, g, b As Integer
Dim x, xb As Double
For i = 0 To gambar.Width - 1
For j = 0 To gambar.Height - 1
r = gambar.GetPixel(i, j).R
g = gambar.GetPixel(i, j).G
b = gambar.GetPixel(i, j).B
x = ((r + g + b) / 3)
gambar2.SetPixel(i, j, Color.FromArgb(x, x, x))
xb = nilaikontras * (r - x) + x
If (xb > 255) Then
xb = 255
ElseIf (xb < 0) Then
xb = 0
End If
gambar.SetPixel(i, j, Color.FromArgb(xb, xb, xb))
Next j
Next i
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.E
ventArgs) Handles Button2.Click
ReDim histogramValues(256)
Dim bmp As New Bitmap(PictureBox1.Image, PictureBox1.Width, PictureBox1.
Height)
Dim bmp2 As New Bitmap(PictureBox2.Image, PictureBox2.Width, PictureBox2
.Height)
PictureBox1.DrawToBitmap(bmp, PictureBox1.ClientRectangle)
PictureBox2.DrawToBitmap(bmp2, PictureBox2.ClientRectangle)
PictureBox1.Image = bmp
PictureBox2.Image = bmp2
For y As Integer = 0 To bmp.Height - 1
For x As Integer = 0 To bmp.Width - 1
Dim r As Integer = bmp.GetPixel(x, y).R
Dim g As Integer = bmp.GetPixel(x, y).G
Dim b As Integer = bmp.GetPixel(x, y).B
Dim Rumus As Single = ((r + g + b) / 3)
histogramValues(Rumus + 1) = histogramValues(Rumus + 1) + 1
bmp.SetPixel(x, y, Color.FromArgb(Rumus, Rumus, Rumus))
Next
Next
PictureBox3.Invalidate()
For y As Integer = 0 To bmp2.Height - 1
For x As Integer = 0 To bmp2.Width - 1
Dim r As Integer = bmp2.GetPixel(x, y).R
Dim g As Integer = bmp2.GetPixel(x, y).G