Add histograms
This commit is contained in:
parent
c7a2890e99
commit
c0b0dacd99
3 changed files with 34738 additions and 0 deletions
|
|
@ -2,3 +2,4 @@ from .interpolate import interpolate
|
||||||
from .random import random
|
from .random import random
|
||||||
from .apply_pixel_shader import apply_pixel_shader
|
from .apply_pixel_shader import apply_pixel_shader
|
||||||
from .get_colour_lut import get_colour_lut
|
from .get_colour_lut import get_colour_lut
|
||||||
|
from .compute_histogram import compute_histogram
|
||||||
|
|
|
||||||
14
editor/utils/compute_histogram.py
Normal file
14
editor/utils/compute_histogram.py
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
from PIL import Image
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
|
def compute_histogram(image_path, bins: int, value_range=(0, 256)):
|
||||||
|
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]
|
||||||
|
)
|
||||||
|
histogram = histogram / np.sum(histogram)
|
||||||
|
|
||||||
|
return histogram.astype(np.float32)
|
||||||
34723
editor/utils/histograms.ipynb
Normal file
34723
editor/utils/histograms.ipynb
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue