Forum Archive

help inverting scikimage.utils.view_as_blocks

jmv38

can anyone help me to invert scikimage.utils.view_as_blocks?
utils.view_as_blocks can make a (128,128) array become (16,16,8,8) so i can work on 8x8 blocks.
But how can I (simply) rebuild the 128x128 original image?
Thank you.
@cpv?

ccc

https://stackoverflow.com/questions/59884413/reverse-skimage-view-as-blocks-with-numpy-reshape ?

cvp

@jmv38 If I am @cpv, I don't know why you think I could help you 😀
I hope @ccc answer will help you

jmv38

@ccc thanks a lot. Strange that i could not find this in ggogle... Notusing the right english words.

jmv38

@cvp sorry for the misspelling. 😜😔

jmv38

@ccc that did it.
For anyone interested, in short:
img is a 4x4 image,
img1 = view_as_blocks(img, block_shape=(2,2))
can be inverted by:
img1.transpose(0,2,1,3).reshape(4,4)