<jupyter_start><jupyter_text>Exam<jupyter_code>import cv2
import numpy as np
from PIL import Image
from matplotlib import pyplot as plt<jupyter_output><empty_output><jupyter_text>Activity 1<jupyter_code>pomme = Image.open("../resources/pomme.jpg")
print(f'Dimensions : width={pomme.size[0]}, height={pomme.size[1]}')
print(f'Mode : {pomme.mode}')

pomme_array = np.array(pomme)
print(f'Mean: {pomme_array.mean()}')
print(f'Min: {pomme_array.min()}')
print(f'Max: {pomme_array.max()}')<jupyter_output>Dimensions : width=500, height=500
Mode : RGB
Mean: 192.12659333333335
Min: 0
Max: 255<jupyter_text>Activity 2<jupyter_code>pomme_original = cv2.imread('../resources/pomme.jpg')
pomme_grey = cv2.cvtColor(pomme_original, cv2.COLOR_BGR2GRAY)
print(f'Pixel(100, 150) = {pomme_grey[150, 100]}')

pomme_grey[50:300,50:400] -= 70

figure, axes = plt.subplots(1, 3)
axes[0].set_title('Original')
axes[0].imshow(cv2.cvtColor(pomme_original, cv2.COLOR_BGR2RGB))
axes[1].set_title('Greyscale')
axes[1].imshow(cv2.cvtColor(pomme_original, cv2.COLOR_BGR2GRAY), cmap='gray')
axes[2].set_title('Modified')
axes[2].imshow(cv2.cvtColor(pomme_grey, cv2.COLOR_GRAY2RGB))
plt.subplots_adjust(wspace=.5)
plt.show()<jupyter_output>Pixel(100, 150) = 254<jupyter_text>Activity 3<jupyter_code>pomme = cv2.imread("../resources/pomme.jpg")
blue, green, red = cv2.split(pomme)

blue_channel = np.zeros_like(pomme)
blue_channel[:, :, 2] = blue

green_channel = np.zeros_like(pomme)
green_channel[:, :, 1] = green

red_channel = np.zeros_like(pomme)
red_channel[:, :, 0] = red

figure, axes = plt.subplots(1, 3)
axes[0].set_title('Blue channel')
axes[0].imshow(blue_channel)
axes[1].set_title('Green channel')
axes[1].imshow(green_channel)
axes[2].set_title('Red channel')
axes[2].imshow(red_channel)
plt.subplots_adjust(wspace=.5)
plt.show()

pomme = cv2.imread("../resources/pomme.jpg")
blue, green, red = cv2.split(pomme)

blue += 40
green += 50
red *=30

new_pomme = cv2.merge([red, green, blue])
plt.imshow(new_pomme)<jupyter_output><empty_output><jupyter_text>Activity 4<jupyter_code>pomme = Image.open("../resources/pomme.jpg")

figure, axes = plt.subplots(2, 2)
axes[0][0].set_title("Rotated 90°")
axes[0][0].imshow(pomme.rotate(90.0))
axes[0][1].set_title("Rotated -90°")
axes[0][1].imshow(pomme.rotate(-90.0))
axes[1][0].set_title("Rotated 45°")
axes[1][0].imshow(pomme.rotate(45.0))
axes[1][1].set_title("Rotated -45°")
axes[1][1].imshow(pomme.rotate(-45.0))
plt.subplots_adjust(hspace=.5)
plt.show()<jupyter_output><empty_output><jupyter_text>Activity 5<jupyter_code>bebe = cv2.imread("../resources/bebe.jpg", cv2.IMREAD_GRAYSCALE)

bebe_histogram = cv2.calcHist([bebe], [0], None, [256], [0, 256])

equalized_bebe = cv2.equalizeHist(bebe)
equalized_bebe_histogram = cv2.calcHist([equalized_bebe], [0], None, [256], [0, 256])


figure, axes = plt.subplots(2, 2)
axes[0][0].set_title("Original")
axes[0][0].imshow(bebe, cmap='gray')
axes[0][1].set_title("Original Histogram")
axes[0][1].plot(bebe_histogram)
axes[1][0].set_title("Equalized")
axes[1][0].imshow(equalized_bebe, cmap='gray')
axes[1][1].set_title("Equalized Histogram")
axes[1][1].plot(equalized_bebe_histogram)
plt.subplots_adjust(hspace=.6)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19206939281288724, 'fraction_numerical': 0.05947955390334572, 'mean_word_length': 8.1994301994302, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '356082', 'license': 'MIT', 'n_tokens_mistral': 1548, 'n_tokens_neox': 1413, 'n_words': 180, 'path': 'Exam/Exam.ipynb', 'repo_name': 'riadh26/Image-Processing-Course', 'size': '3228'}