From: Dave Baldwin Date: 2005-01-26T04:07:00+09:00 Subject: Re: Hacking NArray Hi Brian, I cannot offer any advice on narray, but I have been investigating some image processing algorithms in Ruby. I looked at narray but decided it wasn't worth the effort to understand and holding a 2D image as an array of arrays didn't seem that natural a fit. Also many of the member functions weren't that relevant to what I was going to be doing. My first cut was to implement a simple image class where the image was held in an array and I provided an [x, y] operator to access the data and build on this to add image fill, convolution, stats, thinning, etc.. Even though I was operating on small images (fingerprints) typically 256x256 the performance was not great so I replaced a few key routines such as convolution with c extensions. This improved things somewhat, but as the processing got even more sophisticated performance became an issue again. Most of the image data ended up being held as ruby floats (so took 3 words) - the memory footprint was large as a consequence and a lot of time in my c routines was spent converting between ruby floats and c floats. Finally I rewrote the ruby image class mainly in c with the native pixel data being held in a c array as c floats. Performance and memory footprint are now adequate for my needs. I would advise you to implement your volume class storage and common member functions in c and extend the class with ruby for the high level algorithm control. Processing time grows rapidly when you go into 2D image and even more so for 3D volumes. Try a few experiments in just looping through the volume setting a voxel at a time and you will be convinced! Dave. On 25 Jan 2005, at 16:50, Brian Schræ—¦der wrote: > Hello group, > > I will be busy doing volume data processing the next six months, and I > have decided to use narray for this purpose. > > I'm will shurely have need to implement some functions in c, because > otherwise it will take just too long, but I'd really love to make the > basic structures in ruby. > > So I will have to add custom functions to narray (e.g. right now I > need an inplace abs! operator). This will be a lot of inplace > operations, because when working with volume data even some gigs of > memory are eaten up fast. And I think I will have to extend the fftw > code, to for example include > - inplace dfts, > - saving of plans > > So my question is, if anybody has advice on hacking narray. The code > does not seem too complicated, but it is completely undocumented and I > don't want to duplicate efforts. The other question is, if someone > else has already achieved some of my goals, such that I could reuse > components. > > Thanks a lot, > > Brian >