Improvements

This commit is contained in:
Andras Schmelczer 2024-04-12 20:11:56 +01:00
parent 44e0c129ec
commit 38b21135e2
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
7 changed files with 12038 additions and 16054 deletions

View file

@ -3,14 +3,15 @@ import numpy as np
def compute_histogram(
image_path, bins: int, value_range=(0, 256), normalize: bool = True
image: Image, bins: int, value_range=(0, 256), normalize: bool = True
):
image = Image.open(image_path)
image = np.array(image)
histogram, _ = np.histogramdd(
image.reshape(-1, 3), bins=bins, range=[value_range, value_range, value_range]
).astype(np.float64)
)
histogram = histogram.astype(np.float32)
if normalize:
histogram = histogram / np.sum(histogram)