Exemplo n.º 1
0
def sharper(path, sharper):
    try:
        img = Image.open(path)
        img.filter(ImageFilter.SHARPEN()).show()

        click.secho("Image processed sucesfully!", fg="green", bold=True)
    except Exception as e:
        print(e)
Exemplo n.º 2
0
def Open_Image():
    global img, SAVED
    root.filename = filedialog.askopenfilename()
    if root.filename:
        img = Image.open(root.filename)
        img = img.filter(ImageFilter.SHARPEN())
        img = img.resize((root.winfo_screenwidth(), root.winfo_screenheight()))
        LAYERS_DICT.update({'image': img})
        canvas.image_tk = ImageTk.PhotoImage(img)
        image_id = LAYERS_DICT['canvas'].create_image(0, 0, anchor="nw")
        LAYERS_DICT['canvas'].itemconfigure(image_id, image=canvas.image_tk)
        LAYERS_DICT.update({'img': image_id})
        root.title(f'Shape Editor • {str(root.filename)} •')
        SAVED = True
Exemplo n.º 3
0
 def imgenhance(imgpath):
     img = Image.open(imgpath).convert("L")
     img = img.filter(ImageFilter.SHARPEN())
     enhancer = ImageEnhance.Brightness(img)
     out = enhancer.enhance(1.8)
     nx, ny = out.size
     print("imagesize:", nx, ny)
     out = out.resize((int(nx * 1.5), int(ny * 1.5)), Image.ANTIALIAS)
     print("size:", out.size)
     out.save("/home/caratred/copy/passport/Cleaned1.jpeg", quality=94)
     text = pytesseract.image_to_string(
         Image.open('/home/caratred/copy/passport/Cleaned1.jpeg'))
     os.remove('/home/caratred/copy/passport/Cleaned1.jpeg')
     extract = text.split('\n')
     print(extract)
     return extract
Exemplo n.º 4
0
def imgenhance(imgpath):
    img = Image.open(imgpath).convert("L")  #.histogram()

    img = img.filter(ImageFilter.SHARPEN())
    enhancer = ImageEnhance.Contrast(img)
    out = enhancer.enhance(0.3)
    enhancer = ImageEnhance.Brightness(out)
    out = enhancer.enhance(2.0)
    nx, ny = out.size
    #  print("imagesize:",nx,ny)
    out = out.resize((int(nx * 1.5), int(ny * 1.5)), Image.ANTIALIAS)
    #print("size:",out.size)
    out.save("/home/caratred/copy/passport/Cleaned1.jpeg", quality=94)
    #out.show()
    text = pytesseract.image_to_string(
        Image.open("/home/caratred/copy/passport/Cleaned1.jpeg"))
    print(text)
    extract = text.split('\n')
    print(extract)
    return extract
Exemplo n.º 5
0
def sharpen(input_file):
    input_file = Image.open(input_file)
    sharpened_image = input_file.filter(ImageFilter.SHARPEN())
    sharpened_image.show()
Exemplo n.º 6
0
def sharpen(pixel):
    num = int(input("What is your sharpen power: "))
    original_image = Image.open(input_file)
    sharpened_image = original_image.filter(ImageFilter.SHARPEN(num))
    sharpened_image.show()
    exit()
Exemplo n.º 7
0
from PIL import Image, ImageEnhance, ImageFilter
import pytesseract

image = Image.open(
    '/home/caratred/Downloads/drivers/mrz1.jpeg')  #.convert('L')
image = image.filter(ImageFilter.SHARPEN())
scale_value = 3.
#image = ImageEnhance.Contrast(image).enhance(scale_value)s
image = ImageEnhance.Contrast(image).enhance(1.8)
nx, ny = image.size
print("imagesize:", nx, ny)
img = image.resize((int(nx * 1.5), int(ny * 1.5)), Image.ANTIALIAS)
img.show()
img.save("/home/caratred/savepng.jpeg", quality=94)

im = Image.open("/home/caratred/savepng.jpeg")
im = im.convert('L')
for i in range(2, im.size[0] - 2):
    for j in range(2, im.size[1] - 2):
        b = []
        if im.getpixel((i, j)) > 0 and im.getpixel((i, j)) < 255:
            pass
        elif im.getpixel((i, j)) == 0 or im.getpixel((i, j)) == 255:
            c = 0
            for p in range(i - 1, i + 2):
                for q in range(j - 1, j + 2):
                    if im.getpixel((p, q)) == 0 or im.getpixel((p, q)) == 255:
                        c = c + 1
            if c > 6:
                c = 0
                for p in range(i - 2, i + 3):
Exemplo n.º 8
0
def sharpen(image: Image.Image) -> Image.Image:
    return _apply_filter(image, ImageFilter.SHARPEN())
Exemplo n.º 9
0
 def __call__(self, img):
     if random.random() < self.p:
         img = img.filter(ImageFilter.SHARPEN())
     return img