Forums > Gen

cv.jit.erode in jit.gen?

March 22, 2012 | 8:01 pm

Hi guys, I am wondering how to implement cv.jit.erode in jit.gen.
It doesn’t sound like it would be too hard but it’s got me stumped.

The basic idea behind it is to mark a pixel as on only if all of it’s neighbours are also on.

It also has a function to give each pixel the minimum value of the pixels around it.

I know a little on how to work with planes of data in jit.gen but am not sure how to run functions that refer to individual pixels.


March 22, 2012 | 8:36 pm

You need to use the nearest op in this case. The other alternative is the sample op, but it interpolates, which messes up an erode type operation. nearest takes a coord from [0, 1] to determine which pixel is grabs. To get the coordinate of a pixel offset from the current pixel being processed, you can use the value 1/dim as the delta between pixels:

– Pasted Max Patch, click to expand. –

March 22, 2012 | 10:05 pm

Thanks for the response and the patch.

I seem to get only a few pixels returned from the output of the patch though.

This is your patch v cv.jit.erode

– Pasted Max Patch, click to expand. –

March 22, 2012 | 11:04 pm

The description from the help patch about what the operator does isn’t the entire story. It’s actually more general. Here’s a modified patch that does what the object is doing:

– Pasted Max Patch, click to expand. –

Here’s the actual OpenCV function it’s using:

http://opencv.willowgarage.com/documentation/cpp/image_filtering.html#cv-erode


March 23, 2012 | 12:01 am

Ah this is perfect. Thanks for the open CV source also. I need to practice visualising equations in max. I’ve always had trouble with that.


Viewing 5 posts - 1 through 5 (of 5 total)