12,075,610 members (66,232 online)
Rate this:
See more: , +
hello,
using VS2008 c# [windows mobile 6.5]
how to normalization image (picture) after I take picture with camera.
if result is too dark then add value in all pixel,
otherwise if result is too bright then reduced value pixel of the picture.
"not too bright or dark"
process run automatic after show result and show to picturebox.

please give me sample code
thanks before.
Posted 26-Jun-11 22:23pm
Vivek Krishnamurthy 27-Jun-11 3:25am

Good luck !

Rate this:

## Solution 2

You should perform gamma-correction of the image. Please see this article of comprehensive explanation: http://en.wikipedia.org/wiki/Gamma_correction[^].

Coding this is really trivial and depends on what you're using, `System.Drawing` of WPF.

—SA
Rate this:

## Solution 3

I have C# image processing filters on this very site, try reading my article.
Rate this:

## Solution 1

A way to achieve this is to compute the average intensity of your image and setting the offset constant so that this average becomes 127.

You do this in two passes over the image:
- Pass 1: accumulate all Red, Green, Blue values into an integer variable.
- Compute `Offset= 127 - Accumulator / (3 * pixel count);`
- Pass 2: add the offset to all Red, Green, Blue values, with saturation.

Saturation is done by the following formula: `Red= (Red < 0) ? 0 : ((Red > 255) ? 255 : Red);` and similarly for the other components.

[You may also want to normalize the contrast in addition to the intensity. This implies the computation of both the average and the standard deviation, and applying a linear transform with two constants.]
bagus bujangga 27-Jun-11 22:34pm

I have image 320 * 240 pixel

Pass 1: accumulate (R + G + B)
exp: accumulate = (57+25+154) = 236

Offset = 127 - 236 / (3 * 76800); here 76800 from 320*240
so offset is -4.730902777777778e-4

what wrong??
SAKryukov 27-Jun-11 22:45pm

Don't even try it; the idea is completely incorrect; this is non-linear conversion, will never work as you expect.
--SA
YDaoust 28-Jun-11 3:18am

@Bagus:
Your computation gives 126.99897569444, not -4.730902777777778e-4 (check operator precedence).
But you didn't accumulate, you just took values from a single pixel. You should have computed Offset = 127 - 236 / (3 * 1) = 48.3333, which gives you the corrected pixel (105, 73, 202).
YDaoust 28-Jun-11 3:27am

@SAKKryukov:
Why do you say that Bagus is wrong? His transform has exactly the effect of brightness adjustment as you find on most display screens.

Combined with contrast adjustment, this gives you the very classical way of doing contrast stretching.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Top Experts
Last 24hrsThis month
 OriginalGriff 536 ProgramFOX 300 Dave Kreskowiak 285 CHill60 160 Richard MacCutchan 159
 Dave Kreskowiak 2,796 OriginalGriff 2,690 Richard MacCutchan 1,834 CPallini 1,527 CHill60 1,379

Advertise | Privacy | Mobile
Web03 | 2.8.160208.1 | Last Updated 27 Jun 2011