Coding this is really trivial and depends on what you're using,

`System.Drawing`

of WPF.
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 :D

thanks before.

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 :D

thanks before.

Comments

Vivek Krishnamurthy
27-Jun-11 3:25am

Good luck !

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,

—SA

Coding this is really trivial and depends on what you're using,

`System.Drawing`

of WPF.
Permalink

Share this answer

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

Permalink

Share this answer

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

- Pass 2: add the offset to all Red, Green, Blue values, with saturation.

Saturation is done by the following formula:

[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.]

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.]

Permalink

Share this answer

Comments

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??

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??

Sergey Alexandrovich Kryukov
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

--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).

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.

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)

CodeProject,
20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8
+1 (416) 849-8900