I need to split colour channel of the image (specifically "Cb") in 8x8 blocks in order to modify DCT coefficients and reassemble them back later.
I'm trying to do it using image.extract_patches_2d()
However I can't seem to reassemble the channel
from PIL import Image
from sklearn.feature_extraction import image
import numpy as np
pic = Image.open('lama.png')
pic_size = pic.size
ycbcr = pic.convert('YCbCr')
(y, cb, cr) = ycbcr.split()
acb = np.asarray(cb)
patches = image.extract_patches_2d(acb, (8, 8))
acb2 = image.reconstruct_from_patches_2d(patches, (500,500))
cb_n = Image.fromarray(acb2, 'L')
Even without any changes to the patches reassembled array does not correspond to the original channel:
cb saved as image:
Cb restored from patches (cb_n in code):
So is there something wrong with the code? Or is it impossible to restore colour channel from pathces (blocks) using image.reconstruct_from_patches_2d?
And if so, is there a better way to do what I need?
Thanks for reading, appreciate any help.

