splitting numpy array unevenly

Joshua Landau joshua.landau.ws at gmail.com
Mon Sep 17 20:23:33 EDT 2012


On 17 September 2012 23:31, Wanderer <wanderer at dialup4less.com> wrote:

> I need to divide a 512x512 image array with the first horizontal and
> vertical division 49 pixels in. Then every 59 pixels in after that. hsplit
> and vsplit want to start at the edges and create a bunch of same size
> arrays. Is there a command to chop off different sized arrays?
>

hsplits = [49]
sum_hsplits = 49
while sum_hsplits < 512:

hsplits.append(sum_hsplits)
sum_hsplits += 59


np.split(np.random.rand(512), hsplits)

If I understand correctly, this is a one-dimensional version of what you
want. Extending this to the second dimension should be quite easy.
However, I am not sure if I do understand what you want. Could
you elaborate on what you are trying to achieve?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120918/ff59994d/attachment.html>


More information about the Python-list mailing list