from IPython.display import Image, display
from pathlib import Path  # https://medium.com/@ageitgey/python-3-quick-tip-the-easy-way-to-deal-with-file-paths-on-windows-mac-and-linux-11a072b58d5f

# prepares a series of images
def image_data(path=Path("images/"), images=None):  # path of static images is defaulted
    if images is None:  # default image
        images = [
            {'source': "Peter Carolin", 'label': "Clouds Impression", 'file': "clouds-impression.png"},
            {'source': "Peter Carolin", 'label': "Lassen Volcano", 'file': "lassen-volcano.png"}
        ]
    for image in images:
        # File to open
        image['filename'] = path / image['file']  # file with path
    return images

def image_display(images):
    for image in images:  
        display(Image(filename=image['filename']))


# Run this as standalone tester to see sample data printed in Jupyter terminal
if __name__ == "__main__":
    # print parameter supplied image
    green_square = image_data(images=[{'source': "Internet", 'label': "Green Square", 'file': "green-square-16.png"}])
    image_display(green_square)
    
    # display default images from image_data()
    default_images = image_data()
    image_display(default_images)
from PIL import Image
import numpy as np
def load_image(path):
    image = Image.open(path)
    return np.array(image)
if __name__ == "__main__":
    # Load the image
    image_array = load_image("images/mountain.jpg")
    # Create new arrays for the red, green, and blue channels
    red_array = np.zeros_like(image_array)
    green_array = np.zeros_like(image_array)
    blue_array = np.zeros_like(image_array)
    # Set the red channel to the red value of each pixel
    red_array[:,:,0] = image_array[:,:,0]
    # Set the green channel to the green value of each pixel
    green_array[:,:,1] = image_array[:,:,1]
    # Set the blue channel to the blue value of each pixel
    blue_array[:,:,2] = image_array[:,:,2]
    # Convert the NumPy arrays back to image objects
    red_image = Image.fromarray(red_array)
    green_image = Image.fromarray(green_array)
    blue_image = Image.fromarray(blue_array)
    # Display the images
    red_image.show()
    green_image.show()
    blue_image.show()
WARNING: You don't seem to have any mimeinfo.cache files.
Try running the update-desktop-database command. If you
don't have this command you should install the
desktop-file-utils package. This package is available from
http://freedesktop.org/wiki/Software/desktop-file-utils/
WARNING: You don't seem to have any mimeinfo.cache files.
Try running the update-desktop-database command. If you
don't have this command you should install the
desktop-file-utils package. This package is available from
http://freedesktop.org/wiki/Software/desktop-file-utils/
WARNING: You don't seem to have any mimeinfo.cache files.
Try running the update-desktop-database command. If you
don't have this command you should install the
desktop-file-utils package. This package is available from
http://freedesktop.org/wiki/Software/desktop-file-utils/
No applications found for mimetype: image/png
.No applications found for mimetype: image/png
.No applications found for mimetype: image/png
./usr/bin/xdg-open: 882: x-www-browser: not found
/usr/bin/xdg-open: 882: x-www-browser: not found
/usr/bin/xdg-open: 882: x-www-browser: not found
/usr/bin/xdg-open: 882: firefox: not found
/usr/bin/xdg-open: 882: firefox: not found
/usr/bin/xdg-open: 882: firefox: not found
/usr/bin/xdg-open: 882: /usr/bin/xdg-open: 882: iceweasel: not found
iceweasel: not found
/usr/bin/xdg-open: 882: iceweasel: not found
/usr/bin/xdg-open: 882: /usr/bin/xdg-open: 882: seamonkey: not found
seamonkey: not found
/usr/bin/xdg-open: 882: seamonkey: not found
/usr/bin/xdg-open: 882: /usr/bin/xdg-open: 882: mozilla: not found
mozilla: not found
/usr/bin/xdg-open: 882: mozilla: not found
/usr/bin/xdg-open: 882: /usr/bin/xdg-open: 882: epiphany: not found
epiphany: not found
/usr/bin/xdg-open: 882: epiphany: not found
/usr/bin/xdg-open: 882: /usr/bin/xdg-open: 882: konqueror: not found
konqueror: not found
/usr/bin/xdg-open: 882: konqueror: not found
/usr/bin/xdg-open: 882: /usr/bin/xdg-open: 882: chromium: not found
chromium: not found
/usr/bin/xdg-open: 882: chromium: not found
/usr/bin/xdg-open: 882: /usr/bin/xdg-open: 882: chromium-browser: not found
chromium-browser: not found
/usr/bin/xdg-open: 882: chromium-browser: not found
/usr/bin/xdg-open: 882: /usr/bin/xdg-open: 882: google-chrome: not found
google-chrome: not found
/usr/bin/xdg-open: 882: google-chrome: not found
/usr/bin/xdg-open: 882: /usr/bin/xdg-open: 882: www-browser: not found
www-browser: not found
/usr/bin/xdg-open: 882: www-browser: not found
/usr/bin/xdg-open: 882: /usr/bin/xdg-open: 882: links2: not found
links2: not found
/usr/bin/xdg-open: 882: links2: not found
/usr/bin/xdg-open: 882: /usr/bin/xdg-open: 882: elinks: not found
elinks: not found
/usr/bin/xdg-open: 882: elinks: not found
/usr/bin/xdg-open: 882: /usr/bin/xdg-open: 882: links: not found
links: not found
/usr/bin/xdg-open: 882: links: not found
/usr/bin/xdg-open: 882: /usr/bin/xdg-open: 882: lynx: not found
lynx: not found
/usr/bin/xdg-open: 882: lynx: not found
/usr/bin/xdg-open: 882: /usr/bin/xdg-open: 882: w3m: not found
w3m: not found
xdg-open: no method available for opening '/tmp/tmp35v28x0a.PNG'
xdg-open: no method available for opening '/tmp/tmp7f8ffydu.PNG'
/usr/bin/xdg-open: 882: w3m: not found
xdg-open: no method available for opening '/tmp/tmpzlzdw86r.PNG'