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?
Forum Archive
help inverting scikimage.utils.view_as_blocks
jmv38
Mar 23, 2020 - 21:49
ccc
Mar 23, 2020 - 22:15
https://stackoverflow.com/questions/59884413/reverse-skimage-view-as-blocks-with-numpy-reshape ?
cvp
Mar 23, 2020 - 22:38
@jmv38 If I am @cpv, I don't know why you think I could help you 😀
I hope @ccc answer will help you
jmv38
Mar 23, 2020 - 23:11
@ccc thanks a lot. Strange that i could not find this in ggogle... Notusing the right english words.
jmv38
Mar 23, 2020 - 23:14
@cvp sorry for the misspelling. 😜😔
jmv38
Mar 24, 2020 - 10:28
@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)