Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //условно говоря, ситуация следующая
- double GetAverage (Bitmap image)
- {
- double brightness = 0;
- double product = 1;
- int red = 0, green = 0, blue = 0;
- int quantity = 0;
- for (int x = 0; x < image.Width; x++)
- {
- for (int y = 0; y < image.Height; y++)
- {
- red = image.GetPixel (x, y).R;
- green = image.GetPixel (x, y).G;
- blue = image.GetPixel (x, y).B;
- if (red || green || blue)
- {
- brightness = red*0.299 + green*0.587 + blue*0.114;
- product *= brightness;
- quantity++;
- }
- }
- }
- return Math.Power (product, 1/quantity);
- }
Advertisement
Add Comment
Please, Sign In to add comment