[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*Subject*: Re: Array manipulation*From*: "R.G.S." <noemail(at)toomuch.spam>*Date*: Wed, 1 Nov 2000 10:44:35 -0700*Newsgroups*: comp.lang.idl-pvwave*Organization*: RMI.NET*References*: <39ffa4ae.1813674@news.uwa.edu.au>*Xref*: news.doit.wisc.edu comp.lang.idl-pvwave:21975

Leon Majewski <majewski@cygnus.uwa.edu.au> wrote in message 39ffa4ae.1813674@news.uwa.edu.au">news:39ffa4ae.1813674@news.uwa.edu.au... > Hello > I was wondering whether any array minded person could suggest a way of using array > indicies to chop up a large array into ordered windows. > I can't think of a way to do it with reform, translate (though i'm sure this is my > limitation not a reform translate limitation) > > --------- > ie given an array of 30*30 elements > return 100 3*3 elements > or 36 5*5 > or... > > in= > > 00 01 02 03 04 05.. > 30 31 32 33 34 35.. > 60 61 62 63 64 65.. > > out = blocks such as > 00 01 02 > 30 31 32 > 60 61 62 > > each block is then processed to one representative number (ie mean or median....) and > returned > > ------------ > What i've used so far is attached below (it does what i want, just slowly) > > > leon > (snip) ------------------------- > Leon Majewski > > Remote Sensing & Satellite Research Group > Curtin University of Technology, Perth, Australia > > email: majewski@ses.curtin.edu.au Hi Leon, I am guessing that you can't do this with "reform". Here is a quick array-index solution to extract a (that is, ONE) subarray. Thus, if you have array "a" here which is 12 by 16, and you want a 3 by3 subarray (set piecesize to 3 as done below), then run the code below. The srow and scol are the indices of the subarrays (i.e. your 12 by 15 array can be thought of an array of 4 by 5 blocks, and srow is 0..4-1 and scol is 0..5-1, get it?) It is easy enough to turn this into a function. If you want, this can be turned into a 3d array of indices, if you need to produces indices for all subarrays. If you want that, I can take another look at the indices function. Cheers, bob stockwell stockwell (at) co-ra.com ; create a test case here a = indgen(12,15) ncols = (size(a))(1) ; Assumes square pieces piecesize = 3 ; size of the square subarray (i.e. piecesize by piecesize) srow = 1 ; which row of the possible subsets scol = 2 ; which column of the possible subsets indices = indgen(piecesize,piecesize) +(intarr(piecesize) + 1) # indgen(piecesize) * (ncols - piecesize) +piecesize*srow*ncols + scol*piecesize subarray = a(indices) help,b print,b end

**Follow-Ups**:**Re: Array manipulation (typo fixed)***From:*R.G.S.

**References**:**Array manipulation***From:*Leon Majewski

- Prev by Date:
**Re: Array manipulation** - Next by Date:
**Re: Array manipulation** - Prev by thread:
**Re: Array manipulation** - Next by thread:
**Re: Array manipulation (typo fixed)** - Index(es):