Hi Konrad,
In the original post, I put in the code, it was removed by the post
editor.
The way I wanted it implement, I have the main in java (gui and
stuff). I create a 3D array in java, it's an int array (i.e. int arr[]
[][] ) and call with that array to clojure.

It can be done in java at least 3 orders of magnitude faster so I'm
sure there is something I'm doing wrong.
I'll appreciate any suggestion.
Thanks,
Amnon

I've squeezed my example into two functions:

(defn light [arr x y]
        (+ (aget arr x y 0) (aget arr x y 1) (aget arr x y 2))
        )

(defn grey [arr]
        (dotimes [x (length arr)]
                (dotimes [y (alength (aget  arr 0))]
                        (let [lg (int (/ (light arr x y) 3))]
                                (aset arr x y 0 lg)
                                (aset arr x y 1 lg)
                                (aset arr x y 2 lg)
                        ))))





On Nov 24, 8:35 pm, Konrad Hinsen <konrad.hin...@fastmail.net> wrote:
> On 24 Nov 2009, at 17:30, Amnon wrote:
>
> > I hope it's not the billion time you get the question.
> > I wanted to use clojure for image processing. I have a 3 dimensional
> > array I'm passing to clojure from java.
> > I then loop on the array to manipulate it.
> > Even the simplest task takes about half a minutes (I expected it to be
> > over in less than a second)
>
> Could you give some more details? For example, what is the Java class  
> you use for the 3D arrays? How are you accessing it from Clojure? How  
> do  you do the loops? How do you create the destination array, and how  
> do you fill it with the grey-scale values? I suspect that many of  
> these steps could be optimized, but it's hard to say without knowing  
> how your current code works.
>
> Konrad.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to