<jupyter_start><jupyter_text>Gray graphy<jupyter_code># 
# Based environment:
# 
from __future__ import print_function
from  matplotlib import pyplot as plt
# %matplotlib inline
import cv2
import numpy as np
import pandas as pd
image = cv2.imread("../img_source/must_logo.png")
plt.imshow(image)
plt.title('Original')
plt.show()<jupyter_output><empty_output><jupyter_text>Simple Application
 Average Max and Min<jupyter_code>row, col, channel = image.shape
image_gray = np.zeros((row, col))

# I(x,y) = 0.5 * max(I_R(x,y), I_G(x,y), I_B(x,y))+ 0.5 * min(I_R(x,y), I_G(x,y), I_B(x,y))

for r in range(row):
    for l in range(col):
        image_gray[r, l] = 1 / 2 * max(image[r, l, 0], image[r, l, 1], image[r, l, 2]) + \
                         1 / 2 * min(image[r, l, 0],  image[r, l, 1], image[r, l, 2])
plt.imshow(image_gray)
plt.title('image_maxmin')
plt.show()<jupyter_output><empty_output><jupyter_text>Average Weight<jupyter_code>row, col, channel = image.shape
image_gray = np.zeros((row, col))



for r in range(row):
    for l in range(col):
        image_gray[r, l] = 0.11 * image[r, l, 0]+ 0.59* image[r, l, 1] + 0.3*image[r, l, 2]

plt.imshow(image_gray)
plt.title('image_weight')
plt.show()<jupyter_output><empty_output><jupyter_text>Binary value<jupyter_code>row, col, channel = image.shape
image_gray = np.zeros((row, col))

for r in range(row):
    for l in range(col):
        image_gray[r, l] = 1 / 2 * max(image[r, l, 0], image[r, l, 1], image[r, l, 2]) + 1 / 2 * min(image[r, l, 0],  image[r, l, 1], image[r, l, 2])

image_binary = np.zeros_like(image_gray)

threshold = 100
for r in range(row):
    for l in range(col):
        if image_gray[r, l] >= threshold:
            image_binary[r, l] = 255
        else:
            image_binary[r, l] = 0

plt.imshow(image_gray)
plt.title('image_binary_value')
plt.show()<jupyter_output><empty_output><jupyter_text>Component<jupyter_code>row, col, channel = image.shape
image_gray = np.zeros((row, col))

for r in range(row):
    for l in range(col):
        image_gray[r, l] = 1 / 3 * image[r, l, 0] + 1 / 3 * image[r, l, 1] + 1 / 3 * image[r, l, 2]

plt.imshow(image_gray)
plt.title('image_component')
plt.show()<jupyter_output><empty_output><jupyter_text>Inverse<jupyter_code>row, col, channel = image.shape

image_inverse = np.zeros_like(image)

for r in range(row):
    for l in range(col):
        image_inverse[r, l] = 255 - image[r, l]

plt.imshow(image_inverse)
plt.title('image_inverse')
plt.show()<jupyter_output><empty_output><jupyter_text>Sketch Application<jupyter_code>image_gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
image_gray_inv = 255-image_gray
image_blur = cv2.GaussianBlur(image_gray_inv, (21, 21), 0)
image_blend1 = cv2.divide(image_gray, 255-image_blur, scale=256)
image_blend2 = 255-cv2.divide(255-image_gray, 255-image_blur, scale=256)

plt.subplot(1,4,1)
plt.imshow(image_gray_inv)
plt.title("Inv")
plt.subplot(1,4,2)
plt.imshow(image_blur)
plt.title("Blur")
plt.subplot(1,4,3)
plt.imshow(image_blend1)
plt.title("Blend1")
plt.subplot(1,4,4)
plt.imshow(image_blend2)
plt.title("Blend2")
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15992532669570628, 'fraction_numerical': 0.03298070939639079, 'mean_word_length': 4.062992125984252, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '104329', 'license': 'MIT', 'n_tokens_mistral': 1460, 'n_tokens_neox': 1353, 'n_words': 268, 'path': 'notebooks/04_Gray_graphy.ipynb', 'repo_name': 'Tim-eyes/example_driven_guide_opencv', 'size': '3214'}