Untitled

mail@pastecode.io avatar
unknown
plain_text
6 months ago
918 B
1
Indexable
Never
import sys

import cv2
import numpy as np

from commun.morpho import *
from commun.strel import *
from commun.myutil import *

el = np.ones((11,11),dtype=np.int8)

Mon_elem = build('disk',120)

image = cv2.imread("text4.png",cv2.IMREAD_GRAYSCALE )
cv2.imshow("Rouge", image)

im_close = myclose(image,el)
#cv2.imshow("Image", im_close)

im_open = myopen(image,Mon_elem)
cv2.imshow("Image Open", im_open)

im_without_bag = im_close - image
cv2.imshow("Top HAT", im_without_bag)

s = myseuil_interactif(im_without_bag)
im_bin = seuil(im_without_bag,s)
cv2.imshow("Seuil", im_bin)

cv2.waitKey(0)
cv2.destroyAllWindows()


import cv2

def myerod(im, el):
    return  cv2.erode(im,el)

def mydilat(im,el):
    return cv2.dilate(im,el[::-1,::-1])

def mygrad(im,el):
    return mydilat(im,el) - myerod(im,el)

def myopen(im,el):
    return mydilat(myerod(im,el),el)

def myclose(im,el):
    return myerod(mydilat(im,el),el)