Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #29391 > unrolled thread
| Started by | Wanderer <wanderer@dialup4less.com> |
|---|---|
| First post | 2012-09-17 15:31 -0700 |
| Last post | 2012-09-19 08:26 +0200 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.lang.python
splitting numpy array unevenly Wanderer <wanderer@dialup4less.com> - 2012-09-17 15:31 -0700
Re: splitting numpy array unevenly Martin De Kauwe <mdekauwe@gmail.com> - 2012-09-17 16:43 -0700
Re: splitting numpy array unevenly Wanderer <wanderer@dialup4less.com> - 2012-09-18 07:02 -0700
Re: splitting numpy array unevenly Hans Mulder <hansmu@xs4all.nl> - 2012-09-19 08:26 +0200
| From | Wanderer <wanderer@dialup4less.com> |
|---|---|
| Date | 2012-09-17 15:31 -0700 |
| Subject | splitting numpy array unevenly |
| Message-ID | <e9294cb3-855c-49d1-b98b-22365a4180a8@googlegroups.com> |
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? Thanks
[toc] | [next] | [standalone]
| From | Martin De Kauwe <mdekauwe@gmail.com> |
|---|---|
| Date | 2012-09-17 16:43 -0700 |
| Message-ID | <caed65fe-c29d-4d5f-a752-2a39940e445d@googlegroups.com> |
| In reply to | #29391 |
On Tuesday, September 18, 2012 8:31:09 AM UTC+10, Wanderer 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? > > > > Thanks I don't know that I follow completely, but can't you just slice what you are after? x = np.random.rand(512*512).reshape(512,512) xx = x[0,:49] And put the rest of the slices in a loop...?
[toc] | [prev] | [next] | [standalone]
| From | Wanderer <wanderer@dialup4less.com> |
|---|---|
| Date | 2012-09-18 07:02 -0700 |
| Message-ID | <d7728acf-199a-4cd3-bc59-205e461f9a03@googlegroups.com> |
| In reply to | #29395 |
On Monday, September 17, 2012 7:43:06 PM UTC-4, Martin De Kauwe wrote:
> On Tuesday, September 18, 2012 8:31:09 AM UTC+10, Wanderer 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?
>
> >
>
> >
>
> >
>
> > Thanks
>
>
>
> I don't know that I follow completely, but can't you just slice what you are after?
>
>
>
> x = np.random.rand(512*512).reshape(512,512)
>
> xx = x[0,:49]
>
> And put the rest of the slices in a loop...?
I was trying to avoid the loop. I figured it out. hsplit and vsplit will work. I just need to give it a list of break points. I still need a loop though.
breakPoints = range(49,512,59)
rowArrays = hsplit(InputArray, breakPoints)
OutArrays = []
for r in rowArrays:
OutArrays.append(vsplit(r, breakPoints))
[toc] | [prev] | [next] | [standalone]
| From | Hans Mulder <hansmu@xs4all.nl> |
|---|---|
| Date | 2012-09-19 08:26 +0200 |
| Message-ID | <505965a6$0$6912$e4fe514c@news2.news.xs4all.nl> |
| In reply to | #29432 |
On 18/09/12 16:02:02, Wanderer wrote: > On Monday, September 17, 2012 7:43:06 PM UTC-4, Martin De Kauwe wrote: >> On Tuesday, September 18, 2012 8:31:09 AM UTC+10, Wanderer 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? >> I don't know that I follow completely, but can't you just slice >> what you are after? >> x = np.random.rand(512*512).reshape(512,512) >> xx = x[0,:49] >> And put the rest of the slices in a loop...? > I was trying to avoid the loop. I figured it out. hsplit and vsplit > will work. I just need to give it a list of break points. I still > need a loop though. > breakPoints = range(49,512,59) > rowArrays = hsplit(InputArray, breakPoints) > OutArrays = [] > for r in rowArrays: > OutArrays.append(vsplit(r, breakPoints)) How about a list display: breakPoints = range(49,512,59) rowArrays = hsplit(InputArray, breakPoints) OutArrays = [vsplit(r, breakPoints) for r in rowArrays] In some sense, it's still a loop, but at least it doesn't look like one. Hope this helps, -- HansM
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web