Lossy and Lossless

  • lossy data can reduce data but the original data is not recovered.
  • lossless data lets you restore and recover
    For example, a image's size can be compress by reducing bits and loss some data

Data Compression

Data compression is the reduction of the number of bits needed to represent data and reduce the transmission time.

from IPython.display import Image, display # import the IPython library
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': "Internet", 'label': "Smile face", 'file': "Capture15.jpg"},

        ]
    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': "Capture15.jpg"}])
    image_display(green_square)
    
    # display default images from image_data()
    default_images = image_data()
    image_display(default_images)