Ask Your Question
0

ImageMagick / OpenCV equivalent

asked 2018-03-14 16:47:53 -0600

updated 2018-03-14 16:49:05 -0600

berak gravatar image

Hi.

Sorry for the noob question. I started a project with ImageMagick, and for performance reasons I'm trying to move it to OpenCV. I'm having a hard time to reproduce the exact same steps, and the documentation does not help. Here are the 'convert' operations I use (followed by # openCv when I have found something approaching) :

-negate # cv2.bitwise_not(img)
-normalize # cv2.normalize(img,img,0,255,cv2.NORM_L1)
-contrast-stretch 80%x10% # ???
-threshold 60% # cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)[1] ???
-morphology Erode Octagon:1 # cv2.morphologyEx(img, cv2.MORPH_CLOSE, kernel) ; cv2.erode(img, None, iterations=3)
- blur x2 # cv2.GaussianBlur(img, (3, 3), 0)

Any help would be greatly appreciated.

Thanks.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-03-14 17:40:21 -0600

Tetragramm gravatar image

So apparently -normalize is just -contrast-stretch with specific arguments, so having both is somewhat redundant. Closest thing to -normalize is equalizeHist.

-threshold 60% is not OTSU, it's just using a threshold of 255*60/100.

For -morphology, you need to use getStructuringElement, and instead of doing MORPH_CLOSE, use MORPH_ERODE.

If the -contrast-stretch is really important, you'll have to write your own, and it doesn't say very much detail on how it actually works.

edit flag offensive delete link more

Comments

Thank you.

Contrast stretch is important : I'm trying to isolate a black writing over a noisy gray-ish background. I will post sample as soon as the forum allows me to :)

pabs.agro gravatar imagepabs.agro ( 2018-03-15 03:45:47 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-03-14 16:47:53 -0600

Seen: 765 times

Last updated: Mar 14 '18