<jupyter_start><jupyter_text>This notebook covers:Lesson 2A-L1 Images as Functions - Lesson 2C-L3 Aliasing Import Libraries and Dependencies<jupyter_code>import cv2
import os
import matplotlib.pyplot as plt
%matplotlib inline

IMG = 'imgs/'<jupyter_output><empty_output><jupyter_text>Some Helper Functions<jupyter_code>def show_img(img):
    """
    Function takes an image, and shows the image using pyplot.
    The image is shown in RGB
    """
    img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
    plt.imshow(img)<jupyter_output><empty_output><jupyter_text>Load and Display an Image<jupyter_code>img_path = os.path.join(IMG, 'sea.jpeg')
img = cv2.imread(img_path)
# What is the size of the Image?
print img.shape
# What is the class of the image?
print img.dtype
show_img(img)<jupyter_output>(3264, 4928, 3)
uint8<jupyter_text>Inspect Image ValuesMy image has three channels: Red, Green, and Blue. That's why when selecting the 50th row and 100th column, three values are returned.<jupyter_code>img[50,100]
plt.plot(img[1500,:,2])<jupyter_output><empty_output><jupyter_text>TODO: Extract a 2D slice between rows 101 to 103 and columns 201 to 203 (inclusive)<jupyter_code>extraction = img[101:103,201:203]<jupyter_output><empty_output><jupyter_text>Crop Image<jupyter_code>cropped = img[1700:,300:,:]
show_img(cropped)
# Size of Cropped Image
cropped.shape<jupyter_output><empty_output><jupyter_text>Color Planes<jupyter_code>img_green = img[:,:,1]
plt.imshow(img_green, cmap='gray')<jupyter_output><empty_output><jupyter_text>Adding Pixels<jupyter_code># Load the Dog Image
dog_path = os.path.join(IMG, 'dog.jpeg')
dog = cv2.imread(dog_path)
#dog = cv2.resize
dog = cv2.resize(dog, (img.shape[1], img.shape[0]))
show_img(dog)
summed = dog + img<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11668545659526494, 'fraction_numerical': 0.040586245772266064, 'mean_word_length': 6.959641255605381, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '490158', 'license': 'Apache-2.0', 'n_tokens_mistral': 734, 'n_tokens_neox': 675, 'n_words': 151, 'path': '.ipynb_checkpoints/Lesson 2A-L1-checkpoint.ipynb', 'repo_name': 'tralpha/Computer-Vision-Gatech', 'size': '1774'}