Created
February 24, 2018 23:35
-
-
Save dg1an3/275371651c009e072c6f5bc0535d970f to your computer and use it in GitHub Desktop.
C# Image Histogram
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// for a 2D array of pixels with some pixel type | |
var pixels = new TPixel[100,100]; | |
// turn into a sequence | |
var pixelSequence = pixels.Cast<TPixelType>(); | |
// group the sequence and turn to a dictionary, with pixel values as key and bin count as value | |
var histo = pixelSequence.GroupBy(px => px).ToDictionary(grp => grp.Key, grp => grp.Count()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
quick and dirty histogram (not very efficient) from a 2D pixel array