<jupyter_start><jupyter_text>loading the image<jupyter_code># Load the image
data = np.array(plt.imread('./images/something.jpg'))<jupyter_output><empty_output><jupyter_text>np arrays being immutable - “assignment destination is read-only”Since numpy version 1.16.0 ...https://stackoverflow.com/a/54308748/4409764  displaying the image<jupyter_code>plt.imshow(data)
data.shape
data[110, 100]
data[20, 150]
data[:, :, 1] = 0
# data[:, :, 2] = 0
plt.imshow(data)
plt.show()
# Load the image
data = np.array(plt.imread('./images/something.jpg'))


# Set the red channel in this part of the image to 0
data[0:100, 0:100, 0] = 250

# Set the green channel in this part of the image to 255
data[0:100, 0:100, 1] = 255

# Set the blue channel in this part of the image to 0
data[0:100, 0:100, 2] = 150

# Visualize the result
plt.imshow(data)<jupyter_output><empty_output><jupyter_text>[stackoverflow](https://stackoverflow.com/questions/12201577/how-can-i-convert-an-rgb-image-into-grayscale-in-python)<jupyter_code>def rgb2gray(rgb):
    return np.dot(rgb[...,:3], [0.299, 0.587, 0.114]).astype(int)
img = plt.imread('./images/toy-car.jpg')
toy_car = rgb2gray(img)

toy_car.shape
plt.imshow(toy_car, cmap = plt.get_cmap('gray'))
toy_car[250, 200]
toy_car[200:400, 300:400]=0
plt.imshow(toy_car, cmap = plt.get_cmap('gray'))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16172106824925817, 'fraction_numerical': 0.08679525222551929, 'mean_word_length': 5.454545454545454, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 2, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '303980', 'license': 'MIT', 'n_tokens_mistral': 628, 'n_tokens_neox': 534, 'n_words': 113, 'path': 'intro-to-numpy-image-manipulations.ipynb', 'repo_name': 'mohammedbehjoo/Deep_Architecture_using-AI_in_architecture', 'size': '1348'}