<jupyter_start><jupyter_text>Qn-3  piecewise transformation part(a)<jupyter_code>import cv2
import math
import copy
import numpy as np 
from matplotlib import pyplot as plt 
# read image 
im = cv2.imread('high3.jpg', 0)
# copy image to implement transformation
out_im = copy.copy(img)
# loop to implement peice wise transformation
for i in range(0, im.shape[0]):
    for j in range(0, im.shape[1]):
        if im[i,j] <= 110:
            out_im[i,j] = 2 * im[i,j] + 100
        elif im[i,j] <= 200:
            out_im[i,j] = im[i,j]
        else:
            out_im[i,j] = 255
plt.subplot(121), plt.imshow(im, cmap='gray'), plt.title('Original')
plt.xticks([]), plt.yticks([])
plt.subplot(122), plt.imshow(out_im, cmap='gray'), plt.title('linear transformation')
plt.xticks([]), plt.yticks([])
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1606714628297362, 'fraction_numerical': 0.03357314148681055, 'mean_word_length': 3.8265895953757227, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '391269', 'license': 'MIT', 'n_tokens_mistral': 340, 'n_tokens_neox': 320, 'n_words': 76, 'path': 'Files/Question-3.ipynb', 'repo_name': 'Naagar/Chroma-key-Compositing', 'size': '834'}