opencl implementation of canny edge algorithm on java.awt.image.BufferedImage
I need some help understanding the opencl implementation for the canny edge detection algorithm.
I'm trying to compile and run this with jocl, with a java.awt.image.BufferedImage and I've succeeded in getting the kernals compiling. However, when I pass in the array into the kernal, I get no output and the output of the first stage looks like this:
Please let me know what I'm doing wrong and what else I may be able to do.
The source code looks something like this. I followed the compilation process for canny.cpp and canny.cl
(def canny-stage1 (kernel/load-executive
{:name "stage1_with_sobel"
:file "opencl/canny.cl"
:options "-D WITH_SOBEL -D cn=1 -D TYPE=uchar -D convert_floatN=convert_float -D floatN=float -D GRP_SIZEX=32 -D GRP_SIZEY=8 -D L2GRAD"
:worksize (fn [src _ _ _ _ map _ _ _ _]
[(.getWidth src)
(.getHeight src)])
:arglist [{:type :image
:name :src
:buffer {:input true}
:flags [:read-only]}
{:type :int
:name :src-step}
{:type :int
:name :src-offset}
{:type :int
:name :rows}
{:type :int
:name :cols}
{:type :image
:name :map
:buffer {:output true}
:flags [:write-only]}
{:type :int
:name :map-step}
{:type :int
:name :map-offset}
{:type :float
:name :low-threshold}
{:type :float
:name :high-threshold}]}))
(def input (javax.imageio.ImageIO/read (io/file "lena-1000x1000.jpg"))
(def buffer (BufferedImage. (.getWidth input)
(.getHeight input)
BufferedImage/TYPE_BYTE_GRAY))
(let [offset 0
step (.getWidth input)
rows (.getHeight input)
cols (.getWidth input)]
(canny-stage1 input
step
offset
rows
cols
buffer
step
offset
low-threshold
high-threshold))
(display-image buffer)
The canny.cl is in opencv for a Mat datastructure. I'm looking to compile the code in jocl and use it for java.awt.image.BufferedImage.
above is not even java (but what ?) -- again, i'm afraid, we cannot help you with any of your problems, specific to using some 3rd party wrappers)
it's clojure - which is java. I'm not wrapping anything. It's compiling the canny.cl code and using it on a java.awt.image.BufferedImage object. The byte array is accessible via input.getRaster().getDataBuffer().getData(). I've found this to work with a custom method that also works with Mat but the canny.cl code does not and I'm wondering why the stripes are occuring