Skip to content

Instantly share code, notes, and snippets.

@Miladiouss
Last active July 21, 2020 20:29
Show Gist options
  • Save Miladiouss/86bed5c53595116dfe18ee0a5c84f838 to your computer and use it in GitHub Desktop.
Save Miladiouss/86bed5c53595116dfe18ee0a5c84f838 to your computer and use it in GitHub Desktop.
Image Histogram Transformation.
import numpy as np
from matplotlib import pyplot as plt
import torch
class HistogramTransform(object):
"""
Transforms the distribution of the input tensor to match that
of the list of template histograms corresponding to each channel.
A template historgram must be set initially.
Args:
tensor (numpy.ndarray):
Image to transform; the histogram is computed over the flattened
array
noise_range (float): Default is 0. A uniform noise ranged between
(-noise_range, +noise_range) will be added to pixels randomly.
Returns:
histogram transformed tensor:
The output tensor type matches the input, either numpy.ndarray or torch.Tensor.
"""
def __init__(self, template_histograms):
'''
Args:
template_histograms:
A list of template histograms.
Each template histogram must consist of the tuple
(counts (numpy.ndarray), bins (numpy.ndarray)).
template_histograms is a list of numpy.histogram outputs,
each corresponding to each channel of the input tensor to be transformed.
If 1 channel, still feed as a list, i.e. [(counts, bin)].
Example:
Assuming img is made by ToTensor(some pil image) and has 3 (RGB) channels, one can get the histogram as such:
histR = np.histogram(img[0].numpy().ravel(), bins = 256, range = [0, 1])
histG = np.histogram(img[1].numpy().ravel(), bins = 256, range = [0, 1])
histB = np.histogram(img[2].numpy().ravel(), bins = 256, range = [0, 1])
'''
self.template_histograms = template_histograms
self.num_channels = len(template_histograms)
def __call__(self, tensor, noise_range = 0, dtype = torch.float32):
"""
Transforms the distribution of the input tensor to match that
of the template histogram. If a list of histograms is provided
and it maches the number of channels of the input tensor, each
channel will be transformed with the corresponding histogram.
This funciton utilises histogram_tranform_1D for an easier user interface.
Args:
tensor (numpy.ndarray):
Image to transform; the histogram is computed over the
flattened array for each channel.
noise_range (float): Default is 0. A uniform noise ranged between
(-noise_range, +noise_range) will be added to pixels randomly.
Returns:
histogram transformed tensor:
The output tensor type matches the input, either numpy.ndarray or torch.Tensor.
"""
tensorType = type(tensor)
tensor = np.asanyarray(tensor)
channels = []
for c, templateHisto in enumerate(self.template_histograms):
channels.append(self.histogram_transform_1D(tensor[c], templateHisto, noise_range = noise_range))
transformed_tensor = np.asanyarray(channels)
# Convert to the original type
if tensorType == torch.Tensor:
transformed_tensor = torch.tensor(transformed_tensor, dtype=dtype)
return transformed_tensor
# Core of the computation, to be used by histogram_transform method internally
def histogram_transform_1D(self, tensor, template_histogram, noise_range = 0):
"""
Transforms the distribution of the input tensor to match that
of the template histogram.
Input tensor will be flattened, transformed, and rearranged
to the original shape.
Mainly intended for call by class functions.
Args:
tensor (numpy.ndarray): Image to transform; the histogram is computed
over the flattened array.
template_histogram (tubple of (numpy.ndarray, numpy.ndarray)):
The template histogram consisiting of a tuple of (counts, bins).
See (the output of) numpy.histogram.
noise_range (float): Default is 0. A uniform noise ranged between
(-noise_range, +noise_range) will be added to pixels randomly.
Returns:
histogram transformed array (numpy.ndarray):
The transformed output tensor/image that maches the input
"""
# === Template Histogram ===
# t_... stands for template_
t_counts, t_bins = template_histogram
# t_bin_idx not required
# Take the cumsum of the counts and normalize by the number of pixels to
# Get the empirical cumulative distribution functions
# (maps value --> quantile)
t_quantiles = np.cumsum(t_counts).astype(np.float32)
t_quantiles /= t_quantiles[-1]
# === Input Tensor ===
# Convert to flattened numpy array
tensor = np.asanyarray(tensor)
originalShape = tensor.shape
tensor = tensor.ravel()
# Get counts, bins, and corresponding bin indices for each tensor value
counts, bins = np.histogram(tensor, bins = t_bins)
bin_idx = np.searchsorted(t_bins[:-2], tensor)
# See comments for t_quantiles
quantiles = np.cumsum(counts).astype(np.float32)
quantiles /= quantiles[-1]
# === Histogram Transformation ===
# interpolate linearly to find the pixel values in the template image
# that corresponds most closely to the quantiles for the input tensor
interp_t_values = np.interp(quantiles, t_quantiles, t_bins[:-1])
tensor_transformed = interp_t_values[bin_idx]
noise = np.random.uniform(
low=-noise_range,
high=+noise_range,
size=(len(tensor_transformed))
)
tensor_transformed += noise
tensor_transformed = np.maximum(tensor_transformed, min(t_bins))
return tensor_transformed.reshape(originalShape)
def histo_plot(img, plt_name = ""):
"""
Calculates and plots the histogram of the input image.
img must be a CHW np.array bounded between 0 and 1.
"""
img = np.asanyarray(img)
histR = np.histogram(img[0].ravel(), bins = 256, range = [0, 1])
histB = np.histogram(img[1].ravel(), bins = 256, range = [0, 1])
histG = np.histogram(img[2].ravel(), bins = 256, range = [0, 1])
fig, (ax_left, ax_right) = plt.subplots(
nrows=1,
ncols=2,
gridspec_kw = {'width_ratios':[1, 2]},
figsize=(14, 6)
)
fig.set_facecolor('white')
imgHWC = img.transpose((1, 2, 0))
ax_left.imshow(imgHWC)
ax_left.get_xaxis().set_visible(False)
ax_left.get_yaxis().set_visible(False)
# ax_right.imshow(img2)
Plot = ax_right.scatter;
marker = 'o'
alpha = 0.15
_ = Plot(histR[-1][:-1], histR[0], marker='o', alpha=alpha, color="r");
_ = Plot(histG[-1][:-1], histG[0], marker='o', alpha=alpha, color="g");
_ = Plot(histB[-1][:-1], histB[0], marker='o', alpha=alpha, color="b");
# ax_right.set_ylim(top=200)
ax_right.set_yscale('symlog')
fig.suptitle(plt_name, fontsize=16)
plt.show()
def module_test():
import torchvision.transforms as transforms
TT = transforms.ToTensor()
TPIL = transforms.ToPILImage()
import numpy as np
from PIL import Image
from urllib.request import urlopen
url1 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAAlC+aJAAAbNElEQVR4nC2aybJt6VWdxyz+Yu19%0Azrk3S0FKVCYCG0QEDdxwyy/tt3DYbhGAASMkozIl5b3n7rPWX8zCjfQ7jIhRfYTb8x1ruCCi1sSq%0ArCtJoC4XLRDXUAWSaZWUgrVIacM1K+dpBGmcu9ieBJYexOpkQU8Mz3PSLQLwUIqscDhBk1hp1ahG%0AorbPbVp6bDv2vu542jYEK6qs8F70Wtb8htu5F8S4IDZU1QwtkYTSWmcbEtgHsBqVzcxiZloI4jwK%0AuscIYXZShAvgtZAMWRqlmDknsw4iAdE8rfWeYKfQPaLKRd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Almt4Q75iumuZWF0/gzGUnFt74K1V6/wy8/pRR2Jir914G4kv0xNX3wKn0xTrLSkoMyd6lk6KXSIn%0ALZ+WBXKZDXX7OEbBJlcsmGoRCB43uKzAljBVhpcBh+qhGl4tYKEuEBEzcg7Kf3TCZt1LQlICc8Fl%0AkqwLCZbe4/aWczq7iN0G5wLlV6YQJtzX5ErF+qUo6sm0a0igccNSKDrbN3lhWLPGEOOZ0opP56HF%0A9oZrojTFVuRnyUWXbfC2pMcMxzMeS5yvEDW6jgBbvSVQriV5U8wWarPxl1tAAkiWEcbjsuIp4HOA%0ATLSs4nVATolQaVoIRbL32L7JS6W1HfSapgyOgY6FpJN5xK4nxKZMt77IX/jzfY+F32n5LgaEkS6I%0AGs2blhvqyIqrHxN8XUEMnzy+lMDYYLVINUyP3Nx59CtChWpgvuait1TWR+pglgx8odqIJt3ZgLCt%0AgAy5DEt0A4LLep/xhM0ujisSEGK6Lcg+JQqJ9+0F4mEocnVvcl1YwKPSE49Qa22GFCm6tJzPprKA%0AAR3F+1yfIvSHtryng+w2xk30xvY3vosCsALnbEzN4Z1BLVi2kAvLK5APA4Ph2rUcCJbZAR+Ojn9f%0ALthikQVIqf5mxBllxDg8CnQ5mzsKuBL3K97We+gr8qBIsLcKPMB6la82KVCJacjuUL2DA89bYN1R%0A1ynrc4LEUT+Qi9uo15JU47CNy68ChwCR6WQwz8YuediVNJvyr/lVd3BrnWF1SLaJmCJ4VhqVwR8/%0AcbxaEMHWIYOPGzJfGyp1zGeMkYKO9E85Oox2gx/exNPSRZQOqMrHt+0n4B0sQmXhTLdhQDkXyO1c%0AglrwAQBxiBUEQEMBev1gvQWxqZItzl+aTGSnHx3dkjvCPz5UdUFFYUpCDF15W5mSmfC1wYaVzboL%0AwEiM/dBidCgPMHKS57Nk5Mu5rleEa669L3M21qq6Pa2nqlqZGCX7/wHwipCHUONuywAAAABJRU5E%0ArkJggg=="
# TT automatically converts a PIL image to a CHW torch.tensor bounded between 0 and 1
img1 = TT(Image.open(urlopen(url1)))
img2 = TT(Image.open(urlopen(url2)))
from HistogramTransformClass import histo_plot
import HistogramTransformClass as HTC
# Extract histograms for each channel of the template image
histR2 = np.histogram(img2[0].numpy().ravel(), bins = 256, range = [0, 1])
histB2 = np.histogram(img2[1].numpy().ravel(), bins = 256, range = [0, 1])
histG2 = np.histogram(img2[2].numpy().ravel(), bins = 256, range = [0, 1])
# Create a histogram transformation object, initialize with channel histograms
HT = HTC.HistogramTransform(template_histograms=(histR2, histG2, histB2))
# Transform the image
img3 = HT(img1)
# Plot histograms
histo_plot(img1, "Original Image")
histo_plot(img2, "Template Image")
histo_plot(img3, "Transformed Image")
if __name__ == "__main__":
module_test()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment