.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/06_visual/plot_05_photo_enhancement.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code or to run this example in your browser via Binder. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_06_visual_plot_05_photo_enhancement.py: Photo enhancement: grading an image by eye ========================================== Image enhancement was one of the earliest IEC applications in image processing (Takagi, 2001; Poli and Cagnoni, 1997). Eleven genes — exposure, contrast, saturation, white balance, gamma, highlights, shadows, vignette, sharpening and hue — process a photograph. The simulated user's ideal grade is hidden; it compares the image features of each candidate with those of its ideal. .. GENERATED FROM PYTHON SOURCE LINES 13-15 Starting point and the effect of single genes --------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 15-35 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np import easyiec as ei from easyiec.problems import ImageEnhancement from easyiec.strategies import SequentialGallery problem = ImageEnhancement() mid = problem.space.denormalize(np.full(problem.dim, 0.5)) fig, axes = plt.subplots(2, 5, figsize=(10, 4.4)) for ax, (name, z) in zip(axes.flat, [(None, 0.5)] + [(n, v) for n in ["exposure", "contrast", "saturation", "temperature", "shadows"] for v in (0.1, 0.9)][:9]): x = mid.copy() if name: i = problem.space.names.index(name) x[i] = problem.space.denormalize(np.where(np.arange(problem.dim) == i, z, 0.5))[i] ax.imshow(problem.to_image(x, 160)) ax.set_title("neutral" if name is None else f"{name} {'low' if z < 0.5 else 'high'}", fontsize=8) ax.axis("off") .. image-sg:: /auto_examples/06_visual/images/sphx_glr_plot_05_photo_enhancement_001.png :alt: neutral, exposure low, exposure high, contrast low, contrast high, saturation low, saturation high, temperature low, temperature high, shadows low :srcset: /auto_examples/06_visual/images/sphx_glr_plot_05_photo_enhancement_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 36-41 The sequential gallery ---------------------- Koyama et al. (2020) designed the sequential gallery for exactly this task: each query is a 3×3 grid in a plane through the current best, the user picks the best cell, and a Bayesian model chooses the next plane. .. GENERATED FROM PYTHON SOURCE LINES 41-51 .. code-block:: Python ideal = problem.space.denormalize(problem.ideal) user = ei.SimulatedUser(problem, target=ideal, noise=0.03, seed=5) res = ei.run(problem, SequentialGallery(grid=3), user, generations=10, seed=5) print(f"best utility {res.best_true:.3f} after {res.summary()['queries']} grid choices") fig, axes = plt.subplots(1, 3, figsize=(9, 3.2)) for ax, (lab, x) in zip(axes, [("neutral", mid), ("hidden ideal", ideal), ("after 10 grids", res.best.genome)]): ax.imshow(problem.to_image(x, 200)) ax.set_title(lab, fontsize=9) ax.axis("off") plt.show() .. image-sg:: /auto_examples/06_visual/images/sphx_glr_plot_05_photo_enhancement_002.png :alt: neutral, hidden ideal, after 10 grids :srcset: /auto_examples/06_visual/images/sphx_glr_plot_05_photo_enhancement_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none best utility 0.989 after 10 grid choices .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 3.207 seconds) .. _sphx_glr_download_auto_examples_06_visual_plot_05_photo_enhancement.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/ComplexSystemsIntelligence/easyiec/main?urlpath=lab/tree/notebooks/auto_examples/06_visual/plot_05_photo_enhancement.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_05_photo_enhancement.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_05_photo_enhancement.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_05_photo_enhancement.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_