The example again adopts the CVImage to demonstrate the use of blur filter. It uses the medianBlur() function from the Imgproc module in OpenCV. Detailed description can also be found in the OpenCV tutorial here.
OpenCV and Processing 11
In this example, I demonstrate the use of the image processing module (Imgproc) with the filter2D function. It is similar to the generic Photoshop filter where you can design the convolution matrix. The example references the OpenCV tutorial and uses a sharpen filter. It also uses the CVImage class in the last post.
Here is a screen shot of the Processing window.
OpenCV and Processing 10
I decide to put together the OpenCV and Processing codes into a class to encapsulate the functions. In this example, I extend the original PImage class and create the CVImage class. Besides the constructor, the following functions are the major interfaces:
- toCV() – copy the content of the PImage pixels[] array to the internal Mat variable cvImg; the internal format for the Mat is BGRA.
- fromCV(Mat) – convert a parameter Mat to the internal storage of Mat and pixels[] array; it accepts input of 1, 3, and 4 channels.
- Mat getBGRA() – output the BGRA Mat from the internal Mat storage.
- Mat getBGR() – output the BGR Mat from the internal Mat storage.
- Mat getGrey() – out the greyscale Mat from the internal Mat storage.
OpenCV 3.0.0 release Java build
Similar to the previous post, it is the Java build of the official release of OpenCV 3.0.0 with the 64 bit versions of Linux, Mac OSX, and Windows. It is now available for download here at
OpenCV 3.0.0 Java build (64 bit)
Copy them to the code folder of any Processing sketch to play.