Q: My image is too dark or too bright. How can I adjust the colors of the image?
A: There could be a lot of causes of the too high darkness or brightness. The image can be either over or underexposed, and the not proper lighting conditions can also corrupt the image. Due to the lots of reasons, there are many solutions available to this problem. The not proper lighting and exposing conditions can be eliminated by the histogram equalization (HistDIBEqualization) operation implemented in BIFILTER.OCX. This method will stretch out the pixel values, so the information of the image will not concentrate to a small region of the possible values. It’s important, that using this method, the new value of a pixel depends only on its original value. If a local region dependent method is needed, use the filter methods.
There are many other ways to manipulate the darkness of an image. ColorBrightnessContrast, ColorCMYKLevels, ColorHueSaturation, and GammaCorrectionmethods are also can adjust the colors of an image. These methods are implemented in BIIMAGE.OCX. All the methods above will manipulate all colors of the image. There can be some cases, when adjusting only one color is needed. In this case use ReplaceColor method also implemented in BIIMAGE.OCX. If the preview dialog is shown, the input parameters of the filtering can be changed onscreen, so the optimal properties of the filtering can be tuned.
Code example:
Dim hSourceDib As Long
Dim hResDib As Long
Dim BIFilterObj As Object
Dim BIImageObj As Object
‘ Load the input image
…
Set BIFilterObj = CreateObject("BIFILTER.BIFilterCtrl.1")
hResDib = BIFilterObj. BIFilterObj.HistDIBEqualization(hDib, DispBoth, hWnd)
Set BIFilterObj = Nothing
Set BIImageObj = CreateObject("BIIMAGE.BIImageCtrl.1")
hResDib = BIImageObj. BIImageObj. GammaCorrection(hResDib, 100, 100, 100,
DispBoth, hWnd);
Set BIImageObj = Nothing
‘ Further processing