-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_script.py
More file actions
76 lines (58 loc) · 1.83 KB
/
Copy pathplot_script.py
File metadata and controls
76 lines (58 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# import os
# from matplotlib import pyplot as plt
# import random
# from PIL import Image, ImageOps
# import numpy as np
# import cv2
# path = r"C:\Users\USER\Desktop\muj_tretak\UIM\OCR\five_128.png"
# rows = 1
# columns = 4
# def noisy(image):
# np_image = np.array(image)
# row, col, ch = np_image.shape
# mean = -20
# var = 50
# sigma = var ** 0.5
# gauss = np.random.normal(mean, sigma, (row, col, ch))
# noisy = np_image + gauss
# noisy = np.clip(noisy, 0, 255).astype(np.uint8)
# return Image.fromarray(noisy)
# def mirrored(image):
# return ImageOps.mirror(image)
# def rotated(image):
# angle = random.randint(-40, 40)
# np_image = np.array(image)
# (h, w) = np_image.shape[:2]
# center = (w / 2, h / 2)
# M = cv2.getRotationMatrix2D(center, angle, 1.0)
# rotated_image = cv2.warpAffine(np_image, M, (w, h), flags=cv2.INTER_CUBIC, borderMode=cv2.BORDER_REFLECT)
# return Image.fromarray(rotated_image)
# img = Image.open(path)
# img_noisy = noisy(img)
# img_mirrored = mirrored(img)
# img_rotated = rotated(img)
# fig = plt.figure(figsize=(10, 7))
# fig.add_subplot(rows, columns, 1)
# # showing image
# plt.imshow(img)
# plt.axis('off')
# plt.title("Original")
# # Adds a subplot at the 2nd position
# fig.add_subplot(rows, columns, 2)
# plt.imshow(img_rotated)
# plt.axis('off')
# plt.title("rotated")
# fig.add_subplot(rows, columns, 3)
# plt.imshow(img_noisy)
# plt.axis('off')
# plt.title("Noisy")
# fig.add_subplot(rows, columns, 4)
# plt.imshow(img_mirrored)
# plt.axis('off')
# plt.title("Mirrored")
# plt.show()
import cv2
image_cv2 = cv2.imread(r"C:\Users\USER\Desktop\muj_tretak\UIM\OCR\train_dir\five_img006-00002.png")
print(image_cv2.shape)
img = cv2.imread(r"C:\Users\USER\Desktop\muj_tretak\UIM\OCR\train_dir\five_img006-00003.png")
print(img.shape)