-
Notifications
You must be signed in to change notification settings - Fork 36
/
parallel_image_generator.py
100 lines (76 loc) · 2.35 KB
/
parallel_image_generator.py
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# -*- coding: utf-8 -*-
"""
Created on Fri Nov 9 11:14:26 2018
@author: Gowtham
"""
import numpy as np
import cv2
img = cv2.imread("gray.bmp")
#cv2.imwrite("gray.bmp", img)
#cv2.imshow('image',a)
#cv2.waitKey(0)
#cv2.destroyAllWindows()
#shift 1 bit down
a = np.zeros(img.shape)
for i in range(1, len(img)):
for j in range(len(img[i])):
for k in range(len(img[i][j])):
#print(img[i][j][k])
a[i-1][j][k] = img[i][j][k]
cv2.imwrite('down.bmp', a)
#shift 1 bit up
a = np.zeros(img.shape)
for i in range(len(img)-1):
for j in range(len(img[i])):
for k in range(len(img[i][j])):
#print(img[i][j][k])
a[i+1][j][k] = img[i][j][k]
cv2.imwrite('up.bmp', a)
#shift 1 bit left
a = np.zeros(img.shape)
for i in range(len(img)):
for j in range(1, len(img[i])):
for k in range(len(img[i][j])):
#print(img[i][j][k])
a[i][j-1][k] = img[i][j][k]
cv2.imwrite('left.bmp', a)
#shift 1 bit right
a = np.zeros(img.shape)
for i in range(len(img)):
for j in range(len(img[i])-1):
for k in range(len(img[i][j])):
#print(img[i][j][k])
a[i][j+1][k] = img[i][j][k]
cv2.imwrite('right.bmp', a)
#shift 1 bit down 1 bit left
a = np.zeros(img.shape)
for i in range(1, len(img)):
for j in range(1, len(img[i])):
for k in range(len(img[i][j])):
#print(img[i][j][k])
a[i-1][j-1][k] = img[i][j][k]
cv2.imwrite('leftdown.bmp', a)
#shift 1 bit up
a = np.zeros(img.shape)
for i in range(len(img)-1):
for j in range(len(img[i])-1):
for k in range(len(img[i][j])):
#print(img[i][j][k])
a[i+1][j+1][k] = img[i][j][k]
cv2.imwrite('rightup.bmp', a)
#shift 1 bit left
a = np.zeros(img.shape)
for i in range(len(img)-1):
for j in range(1, len(img[i])):
for k in range(len(img[i][j])):
#print(img[i][j][k])
a[i+1][j-1][k] = img[i][j][k]
cv2.imwrite('leftup.bmp', a)
#shift 1 bit right
a = np.zeros(img.shape)
for i in range(1, len(img)):
for j in range(len(img[i])-1):
for k in range(len(img[i][j])):
#print(img[i][j][k])
a[i-1][j+1][k] = img[i][j][k]
cv2.imwrite('rightdown.bmp', a)