Lapis design effect with opencv and python

Asked

Viewed 68 times

2

I want to get the result of the image further to the right, so I can only get to the middle image using a Canny filter and a Gaussian filter. Does anyone know how I can get this result? inserir a descrição da imagem aqui

import cv2
img = cv2.imread("foto.jpg", 0 )
cany = cv2.Canny(img,100,200)
cany = 255 - cany
cany = cv2.GaussianBlur(cany, (5,5),0)
cv2.imshow('resultado', cany)
cv2.waitKey(0)
cv2.destroyAllWindows()

1 answer

1


import cv2

# abrindo a imagem em escala de cinza
img_gray = cv2.imread('wonder-woman.png', cv2.IMREAD_GRAYSCALE)

# calculando o inverso, 255 é branco 0 é preto e aplicando o blur
img_gray_inv = 255 - img_gray
img_blur = cv2.GaussianBlur(img_gray_inv, (21,21), 0, 0)

# fazemos o blend com o cv2.divide
img_blend = cv2.divide(img_gray, 255 - img_blur, scale = 256)

#salvamos
cv2.imwrite('wonder-woman-v1.png',img_blend)
  1. Convert the color image to grayscale.
  2. Invert the image in grayscale to get a negative.
  3. Apply a Guassian Blur to the negative of step 2.
  4. Combine the grayscale image of step 1 with the blurred negative of step 3 using a Color Dodge.

Entrada

Saída

Source for the resolution you find in this book here.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.