image editor using python

install packages like opencv & numpy 

 import cv2

import numpy as np

num_down=2
num_bilaterial =7
img_rgb =cv2.imread("animesh.jpg")
print(img_rgb.shape)
img_rgb=cv2.resize(img_rgb,(400,400))


#downsampling, bilaterialfilter 
img_color=img_rgb
for _ in range(num_down):
    img_color=cv2.pyrDown(img_color)
for _ in range(num_bilaterial):
    img_color=cv2.bilateralFilter(img_color, d=9,sigmaColor=9,sigmaSpace=7)
for _ in range(num_down):
    img_color=cv2.pyrUp(img_color)

#editing tools 
#image to gray scale
img_gray= cv2.cvtColor(img_rgb,cv2.COLOR_RGB2GRAY)
#bluring the image
img_blur= cv2.medianBlur(img_gray,9)
#thersholding
img_edge= cv2.adaptiveThreshold(img_blur,255,cv2.ADAPTIVE_THRESH_MEAN_C,cv2.THRESH_BINARY,blockSize=9C=6 )

#converting back to color
img_edge= cv2.cvtColor(img_edge,cv2.COLOR_GRAY2RGB)
#preformimg bitwise AND  
img_cartoon= cv2.bitwise_and(img_color,img_edge)

#cv2.imshow("cartoon",img_cartoon)
stack=np.hstack([img_rgb,img_cartoon])
cv2.imshow('stacked image',stack)
cv2.waitKey(0)

output:



Comments

Popular posts from this blog

spealized the work. Be ready for the future

lest just create a basic bot operation in python

scatterplot/ violon plot /histogram /boxplot