找不到关于图像色彩平衡的原理或算法,哪位高手不吝赐教,万分感谢!只需要说明算法或者处理原理,不一定需要代码。跪谢!

解决方案 »

  1.   

    一般采用直方图均衡的办法。这个是thirdapple的fp里的代码:
    你可以去www.aivisoft.net下载整个程序。
    Public Function AutoColorPoise(mBitmap As cDIB, AutoInfo As Label) As Boolean
    Dim i As Long, j As Long
    Dim JumpLines As Long, JumpBits As Long, StepLines As Long, StepBits As Long
    Dim MeanColor(0 To 2) As Single, SumColor(0 To 2) As Long, Bits As Long, GreyColor As Long
    Dim RedTable(0 To 255) As Long, GreenTable(0 To 255) As Long, BlueTable(0 To 255) As Long
    Dim RedValue As Long, GreenValue As Long, BlueValue As Long
    Dim dWidth As Long, dHeight As Long, Scanline As Long, SizeImage As Long
    Dim dPtr As LongdWidth = mBitmap.mWidth - 1: dHeight = mBitmap.mHeight - 1
    SizeImage = mBitmap.SizeImage
    Scanline = mBitmap.Scanline
    dPtr = mBitmap.ImagePtrJumpLines = Int(dHeight / 1500) * Scanline
    StepLines = Int(dHeight / 1500) + 1JumpBits = Int(dWidth / 1500) * 4 + 4
    StepBits = Int(dWidth / 1500) + 1p4Byte0Ptr(0) = dPtrFor i = 0 To dHeight Step StepLines
      For j = 0 To dWidth Step StepBits
        SumColor(0) = SumColor(0) + p4Byte0(0)
        SumColor(1) = SumColor(1) + p4Byte0(1)
        SumColor(2) = SumColor(2) + p4Byte0(2)
        Bits = Bits + 1
        p4Byte0Ptr(0) = p4Byte0Ptr(0) + JumpBits
      Next j
      p4Byte0Ptr(0) = p4Byte0Ptr(0) + JumpLines
    Next iMeanColor(0) = SumColor(0) \ Bits
    MeanColor(1) = SumColor(1) \ Bits
    MeanColor(2) = SumColor(2) \ BitsGreyColor = (MeanColor(0) * 11 + MeanColor(1) * 59 + MeanColor(2) * 30) \ 100BlueValue = GreyColor - MeanColor(0)
    GreenValue = GreyColor - MeanColor(1)
    RedValue = GreyColor - MeanColor(2)AutoInfo.Caption = "红色:" & CStr(RedValue) & " | 绿色:" & CStr(GreenValue) & " | 蓝色:" & CStr(BlueValue)For i = 0 To 255
      RedTable(i) = i + RedValue
      If RedTable(i) > &HFF Then RedTable(i) = &HFF
      If RedTable(i) < &H0 Then RedTable(i) = &H0
      GreenTable(i) = i + GreenValue
      If GreenTable(i) > &HFF Then GreenTable(i) = &HFF
      If GreenTable(i) < &H0 Then GreenTable(i) = &H0
      BlueTable(i) = i + BlueValue
      If BlueTable(i) > &HFF Then BlueTable(i) = &HFF
      If BlueTable(i) < &H0 Then BlueTable(i) = &H0
    Next ip4Byte0Ptr(0) = dPtrFrmMain.AutoPBar.Max = dHeight
    For i = 0 To dHeight
      For j = 0 To dWidth
        p4Byte0(0) = BlueTable(p4Byte0(0))
        p4Byte0(1) = GreenTable(p4Byte0(1))
        p4Byte0(2) = RedTable(p4Byte0(2))
        p4Byte0Ptr(0) = p4Byte0Ptr(0) + 4
      Next j
      FrmMain.AutoPBar.Value = i
    Next iFrmMain.AutoPBar.Max = 100: FrmMain.AutoPBar.Value = 100AutoColorPoise = True
    End Function
      

  2.   

    色彩平衡,就是色彩直方图的均衡化,色阶的归一化
    难道代码也有错么? Public Function AutoColorPoise
    Auto Color Poise
    自动 色彩 平衡