Hi!
Lately I have been playing with approaches to implement multi dimensional arrays in squeak with functionality similar to python's numpy library. The structure I've come up with has a main array class with instance variables pointing to a ByteArray and an array type object. Whenever a message is sent to an array object, it is dispatched to the array type object which in turn will then choose a concrete implementation from a plugin. The code in the plugin is automatically generated from definitions contained in the various array type classes. For an accessor like at: for example I have a concrete implementation as Slang plugin for each data type that casts the ByteArray data to a pointer of the required type. So I have a structure looking like this: class ivars SqArray buffer, arrayType SqArrayType - SqArrayInt8 - SqArrayInt16 - SqArrayFloat32 ..... SqArrayPlugin -> concrete implementations Is this a sensible design for doing something like this in Smalltalk? Am I abusing the Squeak plugin mechanism very badly? And finally, does something better already exist? Any input and constructive criticism is very much appreciated, Danny |
On Fri, Apr 18, 2008 at 10:39:27PM +0200, Danny Chan wrote:
> Hi! Lately I have been playing with approaches to implement > multi dimensional arrays in squeak with functionality similar > to python's numpy library. > > <snip> > > And finally, does something better already exist? SmalLapack already kinda exists: http://ncellier.ifrance.com/Smallapack/ -- Matthew Fulmer -- http://mtfulmer.wordpress.com/ |
Matthew Fulmer wrote:
> On Fri, Apr 18, 2008 at 10:39:27PM +0200, Danny Chan wrote: >> Hi! Lately I have been playing with approaches to implement >> multi dimensional arrays in squeak with functionality similar >> to python's numpy library. >> >> <snip> >> >> And finally, does something better already exist? > > SmalLapack already kinda exists: > http://ncellier.ifrance.com/Smallapack/ > Yes, that's a first attempt toward a scientific library. Unfortunately, if all tests pass on Dolphin and VW (not 100% covergae though), that's not the case of the Squeak version. Still bleding edge with image blocking (win32) or crashing (linux). I also have an unpublished link to FFTW in VW. Nicolas |
Am Samstag, 19. April 2008 12:20:39 schrieb nice:
> Matthew Fulmer wrote: > > On Fri, Apr 18, 2008 at 10:39:27PM +0200, Danny Chan wrote: > >> Hi! Lately I have been playing with approaches to implement > >> multi dimensional arrays in squeak with functionality similar > >> to python's numpy library. > >> > >> <snip> > >> > >> And finally, does something better already exist? > > > > SmalLapack already kinda exists: > > http://ncellier.ifrance.com/Smallapack/ > > Yes, that's a first attempt toward a scientific library. > Unfortunately, if all tests pass on Dolphin and VW (not 100% covergae > though), that's not the case of the Squeak version. Still bleding edge > with image blocking (win32) or crashing (linux). > > I also have an unpublished link to FFTW in VW. > > Nicolas Sounds interesting. There are two things I need in a matrix package, I would be interested if this can be done with Smallapack: I need the ability to generate views into a data set like it is possible in python or Matlab. For example, in python I can do something like this to raw image data in a 2 dimensional matrix: # selects a sub matrix containing every second pixel in each dimension redChannel = image[::2, ::2] # selects a square of 50 pixels in the top left of the image topLeft = redChannel[0:50, 0:50] Each of the sub matrices is a view into the data and does not copy values. Another thing I need quite often is the ability to change the interpretaion of the matrix data buffer on the fly. In python: # charData is an array with n elements of type char charData.dtype = dtype('int16') # now charData is an array with n/2 elements of type short, interpreting the sequence of two bytes as one short If this is not possible, what would be needed to make Smallapack support this? Danny |
Danny Chan wrote:
> > Sounds interesting. There are two things I need in a matrix package, I would > be interested if this can be done with Smallapack: > > I need the ability to generate views into a data set like it is possible in > python or Matlab. For example, in python I can do something like this to raw > image data in a 2 dimensional matrix: > > # selects a sub matrix containing every second pixel in each dimension > redChannel = image[::2, ::2] > # selects a square of 50 pixels in the top left of the image > topLeft = redChannel[0:50, 0:50] > > Each of the sub matrices is a view into the data and does not copy values. > It is possible to access an arbitrary sequence or rows. Also possible to access an arbitrary sequence of columns. So, you can do it in two stages by now. (Easy to enhance). Also, message names are different depending on the type of argument. aMatrix atRow: anInteger. aMatrix atRows: aCollection. I once tried generalized access messages to unify this, but used triple dispatching at that time to handle generalizedAt:and:put:, something quite horrible. I would tend to reify rows and columns accessors if i had to implement it today. Current implementation is to answer a copy like matlab. However, it is easy to implement some kind of viewport object not creating a copy if that is what you want. There is no specific language in Smallapack, so you won't get these short array notations, unless you implement your own language and interpreter. > Another thing I need quite often is the ability to change the interpretaion of > the matrix data buffer on the fly. In python: > > # charData is an array with n elements of type char > charData.dtype = dtype('int16') > # now charData is an array with n/2 elements of type short, interpreting the > sequence of two bytes as one short > > > If this is not possible, what would be needed to make Smallapack support this? > > Danny > Smallapack supports only Floating point datatypes of Lapack (float, double, float complex, double complex). It was intended to perform linear algebra, not image processing. As for the cast hack, I used such horrible thing in Smallapack to extract real part of a complex matrix, pretending they were just made of twice many reals... It is possible to extend Smallapack to handle int, it is just a matter of implementing a subclass. But there is no fast primitive for int implemented in BLAS/LAPACK. However, quite sure BitBlt is already addressing the problem. Cheers Nicolas |
In reply to this post by Danny Chan
> Lately I have been playing with approaches to implement multi > dimensional arrays... What's the intended use? -C |
Am Dienstag, 22. April 2008 20:13:14 schrieb Craig Latta:
> > Lately I have been playing with approaches to implement multi > > dimensional arrays... > > What's the intended use? > > > -C At the moment, mostly for image processing, both of offline images as well as from live image streams captured from hardware. Therefore I need flexible indexing schemes, different data types and some support for basic statistics, later on support for some basic least squares fitting. Probably more things in time. And I must be able to do most things inplace without a lot of copying. Basically I would like to do the things I can do in my favourite environment for scientific computing (python + numpy) in my favourite development environment, and it seems right now, that Smalltalk is starting to become this environment. Danny |
On 24-Apr-08, at 11:54 AM, Danny Chan wrote:
There was a pretty impressive image manipulation package in Squeak a while back; no idea what it is called or even who wrote it... except I'm thinking it was one of the guys in Argentina? tim -- tim Rowledge; [hidden email]; http://www.rowledge.org/tim Why use one word when two polysyllabic agglomerates will do? |
I'm not certain but I suspect Tim is refering to Diego Gomez Deck
http://wiki.squeak.org/squeak/1603 http://wiki.squeak.org/squeak/3765 http://wiki.squeak.org/squeak/2411 Ken On Thu, 2008-04-24 at 13:55 -0700, tim Rowledge wrote: > > On 24-Apr-08, at 11:54 AM, Danny Chan wrote: > > > > > > > At the moment, mostly for image processing, both of offline images > > as well as > > from live image streams captured from hardware. > > > There was a pretty impressive image manipulation package in Squeak a > while back; no idea what it is called or even who wrote it... except > I'm thinking it was one of the guys in Argentina? > > > tim > -- > tim Rowledge; [hidden email]; http://www.rowledge.org/tim > Why use one word when two polysyllabic agglomerates will do? > > > > > > > signature.asc (196 bytes) Download Attachment |
On 24-Apr-08, at 2:08 PM, Ken Causey wrote: > I'm not certain but I suspect Tim is refering to Diego Gomez Deck > > http://wiki.squeak.org/squeak/1603 > http://wiki.squeak.org/squeak/3765 > http://wiki.squeak.org/squeak/2411 That's the stuff - thanks Ken! I was impressed with it, though I'm no image processing expert and my opinion wouldn't really count for much. tim -- tim Rowledge; [hidden email]; http://www.rowledge.org/tim Logic: The art of being wrong with confidence... |
In reply to this post by Danny Chan
May be you are talking about my old PhotoSqueak project, at
http://www.jvuletich.org/Squeak/PhotoSqueak/PhotoSqueak1/ImageProcessingEng.html , http://www.jvuletich.org/Squeak/PhotoSqueak/PhotoSqueak2/DownloadEng.html and http://www.jvuletich.org/Squeak/PhotoSqueak/PhotoSqueakGallery/PhotoSqueakGallery.html Cheers, Juan Vuletich tim Rowledge wrote: > > On 24-Apr-08, at 11:54 AM, Danny Chan wrote: >>> >> >> At the moment, mostly for image processing, both of offline images as >> well as >> from live image streams captured from hardware. > > There was a pretty impressive image manipulation package in Squeak a > while back; no idea what it is called or even who wrote it... except > I'm thinking it was one of the guys in Argentina? > > tim > -- > tim Rowledge; [hidden email]; http://www.rowledge.org/tim > Why use one word when two polysyllabic agglomerates will do? > > > > > ------------------------------------------------------------------------ > > > > ------------------------------------------------------------------------ > > No virus found in this incoming message. > Checked by AVG. > Version: 7.5.524 / Virus Database: 269.23.3/1391 - Release Date: 4/22/2008 8:15 AM > |
On 24-Apr-08, at 6:57 PM, Juan Vuletich wrote: > May be you are talking about my old PhotoSqueak project, Hmm, yes maybe that was what I was thinking about. Interesting that we have two interesting image processor packages. tim -- tim Rowledge; [hidden email]; http://www.rowledge.org/tim Useful random insult:- Suffers from Clue Deficit Disorder. |
In reply to this post by Juan Vuletich-4
Hi!
Both seem to be very interesting, I will definitely have a look. But maybe I should explain a little bit more what I need to do. I am not interested so much in the image chain that is applied to a raw image from a camera source. I am working with camera modules that have raw output, there is almost no image processing applied within the module. I have to analyze the images for defects and problems of the sensor, the optics and the interaction of both. Typical tasks are for example: - Find the optical center from a homogeneously illuminated image - Find specific target structures in the image and try to extract a sharpness measure - Develop an algorithm that allows to quantify dust and flare - Analyze typical optical problems like distortion, chromatic aberration, vignetting - Analyze color shift problems caused by mismatch between sensor and optics / sensor settings - Retrieve different metrics for several regions of interest on the image like color offsets, statistical measures, contrast... All the processing performed on the image later on is quite interesting to me, because I need to take the influence of the image pipe on the final result into account. But my focus is really on the analysis of large matrix data sets. Typically I need 2D matrices for analysis of luminance values only, 3D matrices for analysis of RGB data. I also need 4D matrices for analysis of color data from raw images (in most image sensors, the color information is encoded by having a different color filter on each pixel, and later on retrieving a full RGB value for a pixel by interpolating the color information from neighbouring pixels). So it is really rather data analysis of very differerent data sets , it only happens to be mostly imaging related at the moment. Am Freitag, 25. April 2008 04:04:41 schrieb tim Rowledge: > On 24-Apr-08, at 6:57 PM, Juan Vuletich wrote: > > May be you are talking about my old PhotoSqueak project, > > Hmm, yes maybe that was what I was thinking about. Interesting that we > have two interesting image processor packages. > > tim > -- > tim Rowledge; [hidden email]; http://www.rowledge.org/tim > Useful random insult:- Suffers from Clue Deficit Disorder. |
Free forum by Nabble | Edit this page |