Python - pixelate area of image (skimage.io + cycles)

Viewed 11

It is necessary to pixelate a certain area in the picture using cycles and the average value of rgb colors

Let's say it's a 250:750 and 100:1000 rectangle with a pixel size of 10

I tried to do this, but it paints over with a solid color

from skimage.io import imread
import matplotlib.pyplot as plt
import numpy as np

orig_img = imread('https://interesnoznat.com/wp-content/uploads/gesichtermix_11925868_1671921689718597_1702935533_n.jpg')
test1 = orig_img.copy()

for i in range(250, 750):
  for j in range(100, 1000):
    ip = i + p
    jp = j + p

    r = np.mean(test1[ip:j, i:jp, 0])
    g = np.mean(test1[ip:j, i:jp, 1])
    b = np.mean(test1[ip:j, i:jp, 2])

    test1[ip:j, i:jp, 0] = r
    test1[ip:j, i:jp, 1] = g
    test1[ip:j, i:jp, 2] = b

plt.imshow(test1)
plt.show()

But it turns out like this (screenshot)

0 Answers
Related