diff --git a/histogram.mbt b/histogram.mbt new file mode 100644 index 0000000..015035c --- /dev/null +++ b/histogram.mbt @@ -0,0 +1,32 @@ +///| +/// Public histogram API. The luma histogram reuses the same 256-bin +/// BT.601 integer binning that Otsu and histogram equalization are built +/// on, so every consumer of the library sees one consistent definition. + +///| +/// 256-bin luma histogram (BT.601 integer weights): `result[v]` counts the +/// pixels whose luma is exactly `v`. +pub fn Image::histogram_luma(self : Image) -> FixedArray[Int] { + self.luma_histogram() +} + +///| +/// Per-channel 256-bin histograms, returned as `(red, green, blue)`. +pub fn Image::histogram_rgb( + self : Image, +) -> (FixedArray[Int], FixedArray[Int], FixedArray[Int]) { + let hr = FixedArray::make(256, 0) + let hg = FixedArray::make(256, 0) + let hb = FixedArray::make(256, 0) + let n = self.pixel_count() + for p in 0.. Self pub fn Image::get_pixel(Self, Int, Int) -> (Byte, Byte, Byte, Byte) pub fn Image::grayscale(Self) -> Self pub fn Image::histogram_equalize(Self) -> Self +pub fn Image::histogram_luma(Self) -> FixedArray[Int] +pub fn Image::histogram_rgb(Self) -> (FixedArray[Int], FixedArray[Int], FixedArray[Int]) pub fn Image::hue_rotate(Self, Double) -> Self pub fn Image::integral_image(Self) -> Integral pub fn Image::invert(Self) -> Self