Perbaikan Kualitas Citra

  • View
    54

  • Download
    1

Embed Size (px)

DESCRIPTION

perbaikan kualitas citra dengan VB

Transcript

Inggih Permana 10751000018

1. Peregangan Kontras (Contrast Stretching) Setelah mencoba rumus yang ada di diktat yaitu S = ((R Rmax)/(Rmin Rmax))*255, hasil yang didapat seperti invert, berikut screen shoot nya:

Tetapi setelah mencari referensi lain dan mendapatkan rumus S = ((R Rmin)/(Rmax Rmin))*255, hasil yang didapat sebagai berikut:

Berikut source code nyaSub PerengganganKontras(pfIndex As Integer) Dim pX As Long, pY As Long Dim x As Long, y As Long Dim MaxRed, MaxGreen, MaxBlue As Long Dim MinRed, MinGreen, MinBlue As Long Dim colorval As Long Dim red As Long, green As Long, blue As Long Dim red2 As Long, green2 As Long, blue2 As Long MaxRed = 0 MaxGreen = 0 MaxBlue = 0 MinRed = 255 MinGreen = 255 MinBlue = 255 pX = mdiImgProcess.ActiveForm.pcbPicture.ScaleWidth - 1 pY = mdiImgProcess.ActiveForm.pcbPicture.ScaleHeight - 1 For x = 0 To pX For y = 0 To pY colorval = GetPixel(hDCSour(pfIndex), x, y) red = GetRed(colorval) green = GetGreen(colorval) blue = GetBlue(colorval) If MaxRed < red Then MaxRed = red If MaxGreen < green Then MaxGreen = green If MaxBlue < blue Then MaxBlue = blue If MinRed > red Then MinRed = red If MinGreen > green Then MinGreen = green If MinBlue > blue Then MinBlue = blue Next y Next x For x = 0 To pX For y = 0 To pY colorval = GetPixel(hDCSour(pfIndex), x, y) red = GetRed(colorval) green = GetGreen(colorval) blue = GetBlue(colorval) red2 = ((red - MinRed) / (MaxRed - MinRed)) * 255 green2 = ((green - MinGreen) / (MaxGreen - MinGreen)) * 255 blue2 = ((blue - MinBlue) / (MaxBlue - MinBlue)) * 255 If If If If If If red2 >= 255 Then red2 = 255 green2 >= 255 Then green2 = 255 blue2 >= 255 Then blue2 = 255 red2