Click here to Skip to main content
11,926,961 members (51,104 online)
Rate this:
Please Sign up or sign in to vote.
See more: VS2008 C# Visual-Studio image , +
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 Big Grin | :-D
thanks before.
Posted 26-Jun-11 22:23pm
Vivek Krishnamurthy 27-Jun-11 3:25am
Good luck !
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

You should perform gamma-correction of the image. Please see this article of comprehensive explanation:[^].

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

Rate this: bad
Please Sign up or sign in to vote.

Solution 3

I have C# image processing filters on this very site, try reading my article.
Rate this: bad
Please Sign up or sign in to vote.

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.
YDaoust 28-Jun-11 3:18am
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
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.151126.1 | Last Updated 27 Jun 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100