DuckQueen
DuckQueen

Reputation: 810

How to implement a Photoshop like effect OilPaint effect in OpenCV?

So the closest of what I found is this Mathematica implementation. Yet Mathematica is not opensource nor easily includable in other applications... So I wonder how to do Photoshop like effect OilPaint effect in OpenCV?

Example input data: enter image description here

Example Result: enter image description here

Example Difference (note one can not really detect in difference-image any patterns not included in processing result): enter image description here

And the best thing is it processed image looks close to what experts see in original image: enter image description here

Images source.

So how to implement a Photoshop like effect OilPaint effect in OpenCV (in Python or C++)?

Upvotes: 2

Views: 3438

Answers (1)

fmw42
fmw42

Reputation: 53164

Here is a classic form of the oil painting effect in Python/OpenCV. Simply apply some morphology open to the image and then brighten the darker regions a little using cv2.normalize.

Input:

enter image description here

import cv2
import numpy as np

# load image
img = cv2.imread("windmill.jpg")

# apply morphology open to smooth the outline
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (6,6))
morph = cv2.morphologyEx(img, cv2.MORPH_OPEN, kernel)

# brighten dark regions
result = cv2.normalize(morph,None,20,255,cv2.NORM_MINMAX)

# write result to disk
cv2.imwrite("windmill_oilpaint.jpg", result)

cv2.imshow("IMAGE", img)
cv2.imshow("OPEN", morph)
cv2.imshow("RESULT", result)
cv2.waitKey(0)
cv2.destroyAllWindows()


enter image description here

Upvotes: 4

Related Questions