Jeew
Jeew

Reputation: 9

Conversion between opencv and javacv

I'm thinning an binary image. I found code done by using opencv. Here is the code.

eroded = cv2.erode(img,element)
temp = cv2.dilate(eroded,element)
temp = cv2.subtract(img,temp)
skel = cv2.bitwise_or(skel,temp)
img = eroded.copy()

I'm trying to convert this code to java via javacv. Both erosion and dilation completed successfully as follows.

skelImg=cvCloneImage(otsuImg);
cvErode(otsuImg, skelImg, null, 1);
cvDilate(skelImg, skelImg, null, 1);

But I couldn't find javacv code for cv2.subtract(IplImage,IplImage). Can someone help me out with this?

Upvotes: 0

Views: 642

Answers (2)

Bull
Bull

Reputation: 11941

Rather than use the javacv wrapper to OpenCV's deprecated API, consider using the following methods from OpenCV's official Java API:

org.opencv.imgproc.Imgproc.erode

org.opencv.imgproc.Imgproc.dilate

org.opencv.core.Core.subtract

org.opencv.core.Core.bitwise_or

Upvotes: 0

sop
sop

Reputation: 3625

There is one subtract function in Core. See this for better understanding

Upvotes: 1

Related Questions