Sitemap

Cumulative Histogram

Photogrammetry-1

Aug 10, 2023

--

I had previously written about Image Histogram here:

A cumulative histogram sums the number of pixels having the current value or smaller than the current value.

The following function computes the cumulative histogram

# 1. Import modules
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
import skimage.io
from skimage import img_as_ubyte
import math

def cumulativeHistogram(hist):

"""The function takes as input a histogram [np.array] and returns the cumulative histogram [np.array]"""

cum_hist = np.zeros((256,1))

for i in range(256):

cum_hist[i] = sum(hist[:i+1])

return cum_hist

--

--