<jupyter_start><jupyter_text>Histogram matching Dr. <NAME>, Fremont, CA 94536This example demonstrates the feature of histogram matching. It manipulates the pixels of an input image so that its histogram matches the histogram of the reference image. If the images have multiple channels, the matching is done independently for each channel, as long as the number of channels is equal in the input image and the reference.Histogram matching can be used as a lightweight normalisation for image processing, such as feature matching, especially in circumstances where the images have been taken from different sources or in different conditions (i.e. lighting).<jupyter_code>import matplotlib.pyplot as plt

from skimage import data
from skimage import exposure
from skimage.transform import match_histograms<jupyter_output><empty_output><jupyter_text>Prepare the images<jupyter_code>reference = data.coffee()
image = data.chelsea()

matched = match_histograms(image, reference, multichannel=True)<jupyter_output><empty_output><jupyter_text>Show<jupyter_code>fig, (ax1, ax2, ax3) = plt.subplots(nrows=1, ncols=3, figsize=(8, 3),
                                    sharex=True, sharey=True)
for aa in (ax1, ax2, ax3):
    aa.set_axis_off()

ax1.imshow(image)
ax1.set_title('Source')
ax2.imshow(reference)
ax2.set_title('Reference')
ax3.imshow(matched)
ax3.set_title('Matched')

plt.tight_layout()
plt.show()<jupyter_output><empty_output><jupyter_text>Matching histogram of classic paintings<jupyter_code>reference = plt.imread("Images/Starry_Night.jpg",format='jpeg')
image = data.chelsea()

matched = match_histograms(image, reference, multichannel=True)
fig, (ax1, ax2, ax3) = plt.subplots(nrows=1, ncols=3, figsize=(9, 9))
for aa in (ax1, ax2, ax3):
    aa.set_axis_off()

ax1.imshow(image)
ax1.set_title('Source')
ax2.imshow(reference)
ax2.set_title('Reference')
ax3.imshow(matched)
ax3.set_title('Matched')

plt.tight_layout()
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10309801929913662, 'fraction_numerical': 0.018791264601320468, 'mean_word_length': 6.242647058823529, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '133050', 'license': 'MIT', 'n_tokens_mistral': 670, 'n_tokens_neox': 642, 'n_words': 178, 'path': 'Histogram_matching.ipynb', 'repo_name': 'tirthajyoti/Scikit-image-processing', 'size': '1981'}