## Python 3 OpenCV Script to Smoothen or Sharpen Input Image Using Numpy Library Full Project For Beginners

`pip install opencv-python`

`pip install numpy`

`app.py`

``````import cv2 as cv
import numpy as np

def unsharp_mask(image, kernel_size=(5, 5), sigma=1.0, amount=1.0, threshold=0):
"""Return a sharpened version of the image, using an unsharp mask."""
blurred = cv.GaussianBlur(image, kernel_size, sigma)
sharpened = float(amount + 1) * image - float(amount) * blurred
sharpened = np.maximum(sharpened, np.zeros(sharpened.shape))
sharpened = np.minimum(sharpened, 255 * np.ones(sharpened.shape))
sharpened = sharpened.round().astype(np.uint8)
if threshold > 0:
low_contrast_mask = np.absolute(image - blurred) < threshold
{"ft_lang_label":"__label__en","ft_lang_prob":0.5056522,"math_prob":0.96919173,"size":827,"snap":"2021-43-2021-49","text_gpt3_token_len":241,"char_repetition_ratio":0.18955043,"word_repetition_ratio":0.0,"special_character_ratio":0.2636034,"punctuation_ratio":0.24,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99781305,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-12-03T05:03:24Z\",\"WARC-Record-ID\":\"<urn:uuid:47853c18-1f7a-4c44-a5d2-cd23819b155e>\",\"Content-Length\":\"88862\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:fe01dfb7-a04b-411e-b564-a5807082ed92>\",\"WARC-Concurrent-To\":\"<urn:uuid:fc121e8d-e842-45cd-b394-db836de92ebd>\",\"WARC-IP-Address\":\"3.234.104.255\",\"WARC-Target-URI\":\"https://codingshiksha.com/python/python-3-opencv-script-to-smoothen-or-sharpen-input-image-using-numpy-library-full-project-for-beginners/\",\"WARC-Payload-Digest\":\"sha1:VZOJVELJBBVF4AWSAPUV7E6O7E6SANLF\",\"WARC-Block-Digest\":\"sha1:KFAVVCULQFDMHKWZ6IILWSHJNXL5JBNW\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-49/CC-MAIN-2021-49_segments_1637964362589.37_warc_CC-MAIN-20211203030522-20211203060522-00321.warc.gz\"}"}