Problem with brightness of image by using SetBrightness

Discussions about image processing and document imaging.
Post Reply
dat024024
Posts: 4
Joined: Fri Jan 25, 2013 3:54 am

Problem with brightness of image by using SetBrightness

Post by dat024024 » Fri Jan 25, 2013 4:15 am

Hi all,

I'm using GdPicture 9 and try to apply Brightness & Contrast for images.

1. Image is imported from scan and set pixel type as below:
oGdPictureImaging.TwainSetPixelType(TwainPixelType.TWPT_BW);
oGdPictureImaging.TwainSetBitDepth(1);
2. When finisht import image, program allow user can change Brightness & Contrast.
oGdPictureImaging.SetBrightness(ImageID, brightnessValue);
oGdPictureImaging.SetContrast(ImageID, contrastValue);

The result is not good with me.
- Set Contrast = 0, user change brightness = -100 -> image to darkness -> OK
- Set Contrast = 0, user change brightness from 20 ~ 100 -> brightness of image seem not change.

I refer to "GDPicture Document Clean up Demo" sample of GDPicture library and the phenomenon is same.

I try to open this image with Picture Manager of Microsoft Office 2010 (PIM), and do same actions (change brightness 20 ~100) -> the image is bright and change to white.
I think behavior of PIM that is right because user change brightness of image to maximum and image so white.

Please tell me about the difference and how to use function brightness of GDPicture to have a behavior look like PIM?

Thanks.

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Problem with brightness of image by using SetBrightness

Post by Loïc » Fri Jan 25, 2013 2:08 pm

Hello,

There are different ways to adjust Brightness of an image. As my humble opinion, GdPicture uses the most efficient method.

Basically we scale each color component by a factor based on the provided parameter. In case you will use 100 the scale factor will be 2.

IE:

Code: Select all

double scale = (100 + parameter) / 100;
component = clamp(component * scale);
This means that black "colors" (0, 0, 0) will never change. This is quite logic in a colorimetric point of view.

What you seem to want is to turn black (0, 0, 0) to white (255, 255, 255) for a parameter of 100. As my opinion this is totally illogical, or at least this has nothing to do with a brightness adjustment. This is more Increasing/decreasing each color channel.

To do that you just have to use the AdjustRGB() method of the Imaging class. Here an example:

Code: Select all

Dim add As Integer = CInt(parameter * 2.55) 'parameter  should be a value from -100 to 100
Imaging1.AdjustRGB(m_CurrentImage, add, add, add)
Let me know if you need more information.

With best regards,

Loïc

dat024024
Posts: 4
Joined: Fri Jan 25, 2013 3:54 am

Re: Problem with brightness of image by using SetBrightness

Post by dat024024 » Mon Jan 28, 2013 11:19 am

Hi Loïc,
I solved my problem, thanks you for your quickly response and effort!

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests