<jupyter_start><jupyter_text>1. read image from path2. convert it to grayscale image3. plot image4. write image to a png file<jupyter_code>path = 'https://upload.wikimedia.org/wikipedia/en/thumb/7/7d/Lenna_%28test_image%29.png/440px-Lenna_%28test_image%29.png'
np_image = imageio.imread(path)
pil_image = Image.fromarray(np_image)
gray_scaled = pil_image.convert('L')
gray_scaled.save('lena_gray.png')
display(gray_scaled)<jupyter_output><empty_output><jupyter_text>plot histogram of gray scaled image<jupyter_code>histogram = np.array(gray_scaled.histogram())
histogram = histogram/sum(histogram) # normalized
x = np.arange(256)
plt.plot(x,histogram)
plt.title('Histogram of lena')
plt.show()<jupyter_output><empty_output><jupyter_text>rotate images 60 degrees<jupyter_code>from skimage.transform import rotate
rotated = rotate(np.array(gray_scaled), 60 , resize=True)
plt.imshow(rotated,cmap='gray')
plt.axis('off')
plt.show()<jupyter_output><empty_output><jupyter_text>resize images to 600x600 and show both images<jupyter_code>from skimage.transform import rotate,resize
display(gray_scaled)
resized = gray_scaled.resize((600,600))
display(resized)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12521150592216582, 'fraction_numerical': 0.030456852791878174, 'mean_word_length': 9.025423728813559, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 1, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '596407', 'license': 'MIT', 'n_tokens_mistral': 473, 'n_tokens_neox': 434, 'n_words': 70, 'path': 'notebooks/basics/solutions/image_processing/image_processing_solutions.ipynb', 'repo_name': 'AIMed-Team/edu-content', 'size': '1182'}