Skip to content
Advertisement

How to Divide an array in to segments and then do sub segments of the segments using python numpy?

I want to do divide an 8*8 array in to 4 segments(each segment of 4*4 array) as shown below in step2. Then again divide each segment in to other small 4 subsegemnts(each subsegment of 2*2 array) and then find the mean of each subsegment and then find the stabbndard deviation of each segment using the 4 means of the 4 subsegments in it. So that finally I only have an array (2*2 array) ie with 1 standard deviation for 1 segment.

JavaScript

upto this I have tried but I was unable to go further in my requirement as I am completely new to python and numpy. Kindly, help me in achieve my requirement.

JavaScript

Expected Output

JavaScript

Advertisement

Answer

It can be done using a function view_as_blocks of skimage.util.shape.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement