Ask Your Question

Revision history [back]

How can i apply mask to image using JavaCV?

I am trying to implement the Hog Descriptor using java without using Hog descriptor which is implemented in opencv, but I have the following questions:

I want to apply Simple 1-D [-1,0,1] masks to an image using javacv

I found the following code but it's for image sharpening

/**

* Use kernel convolution to sharpen an image. */ object Ex3Sharpen extends App {

// Read input image
val image = loadAndShowOrExit(new File("data/boldt.jpg"), CV_LOAD_IMAGE_COLOR)

// Define output image
val dest = IplImage.create(cvGetSize(image), image.depth, 3)

// Construct sharpening kernel, oll unassigned values are 0
val kernel = CvMat.create(3, 3, CV_32F)
kernel.put(1, 1, 5)
kernel.put(0, 1, -1)
kernel.put(2, 1, -1)
kernel.put(1, 0, -1)
kernel.put(1, 2, -1)

// Filter the image
filter2D(image, dest, -1, kernel, new CvPoint(-1, -1), 0, BORDER_DEFAULT)

// Display
show(dest, "Sharpened")

}

How can I be apply this code to perform Simple 1-D [-1,0,1] masks? or How can i apply mask to image using JavaCV?

Regards! Thanks in advance !