---Histogram of basic image transformation

Source: Internet
Author: User
Tags first row
image histogram calculation function

[Algorithm description]

The image histogram describes the number of pixels in the image that have the same grayscale level, which is the function of the image grayscale. In a planar coordinate system, if the gray level (0-255) is represented by a horizontal axis, the ordinate represents the number of pixels in that grayscale level. The formula is expressed as follows:

Where hi represents the distribution function of the grayscale histogram, I represents the grayscale level, NI represents the number of pixels corresponding to the gray level I (here take 8-bit grayscale).

Fig.1 histogram diagram

In Figure Fig.1, the left describes the entire image pixel gray level, the upper right of the table, the second line describes the first row of the number of gray-level pixels, based on this table to draw a histogram as shown in the bottom right image of Fig.1.

[function Code]

///

Get the array of Histrgram.

///

The source image.

///

public static int[] Gethistogramarray (writeablebitmap src)////34 image histogram calculation

{

if (src! = null)

{

int[] histogram = new int[256];

int gray = 0;

byte[] temp = src. Pixelbuffer.toarray ();

for (int i = 0; i < temp. Length; i + = 4)

{

Gray = (int) (Temp[i] * 0.114 + temp[i + 1] * 0.587 + temp[i + 2] * 0.299);

histogram[gray]++;

}

return histogram;

}

Else

{

return null;

}

}

}

}


Demo Download: http://www.zealfilter.com/forum.php?mod=viewthread&tid=20&extra=page%3D2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.