12,405,303 members (62,480 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.

thanks before.
Posted 26-Jun-11 21:23pm
Vivek Krishnamurthy 27-Jun-11 3:25am

Good luck !

Rate this:

## Solution 2

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.

Top Experts
Last 24hrsThis month
 OriginalGriff 311 ppolymorphe 245 Karthik Bangalore 200 Suvendu Shekhar Giri 185 Richard Deeming 145
 OriginalGriff 7,651 Karthik Bangalore 3,327 ppolymorphe 3,260 Richard MacCutchan 2,472 F-ES Sitecore 2,300