shubham680 commited on
Commit
87184ce
·
verified ·
1 Parent(s): 7a05aa1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -5
app.py CHANGED
@@ -64,18 +64,29 @@ def translation(img):
64
  ty=45 #np.random.randint(2,55)
65
  tm=np.array([[1,0,tx],[0,1,ty]],dtype=np.float32)
66
  trans_img=cv2.warpAffine(img,tm,dsize=(img.shape[1],img.shape[0]),borderMode=cv2.BORDER_REFLECT)
67
- img_rgb = cv2.cvtColor(trans_img, cv2.COLOR_BGR2RGB)
68
- st.image(img_rgb, caption="Translation Applied", use_container_width=True)
69
 
70
  def rotation(img):
71
  #center = (width//2, height//2)
72
  angle=90
73
  r_x=img.shape[0]//2
74
  r_y=img.shape[1]//2
75
- rm=cv2.getRotationMatrix2D((r_x,r_y),angle,1)
76
  r_img=cv2.warpAffine(img,rm,(img.shape[1],img.shape[0]))
77
- img_rgb = cv2.cvtColor(r_img, cv2.COLOR_BGR2RGB)
78
- st.image(img_rgb, caption="Rotation Applied", use_container_width=True)
 
 
 
 
 
 
 
 
 
 
 
79
 
80
 
81
  if uploaded_file is not None:
@@ -93,6 +104,7 @@ if uploaded_file is not None:
93
  rotation(img)
94
  transformation.append("Rotation")
95
  if scal:
 
96
  transformation.append("Scaling")
97
  if shearing:
98
  transformation.append("Shearing")
 
64
  ty=45 #np.random.randint(2,55)
65
  tm=np.array([[1,0,tx],[0,1,ty]],dtype=np.float32)
66
  trans_img=cv2.warpAffine(img,tm,dsize=(img.shape[1],img.shape[0]),borderMode=cv2.BORDER_REFLECT)
67
+ img_trans_rgb = cv2.cvtColor(trans_img, cv2.COLOR_BGR2RGB)
68
+ st.image(img_trans_rgb, caption="Translation Applied", use_container_width=True)
69
 
70
  def rotation(img):
71
  #center = (width//2, height//2)
72
  angle=90
73
  r_x=img.shape[0]//2
74
  r_y=img.shape[1]//2
75
+ rm=cv2.getRotationMatrix2D((r_y,r_x),angle,1)
76
  r_img=cv2.warpAffine(img,rm,(img.shape[1],img.shape[0]))
77
+ img_rot_rgb = cv2.cvtColor(r_img, cv2.COLOR_BGR2RGB)
78
+ st.image(img_rot_rgb, caption="Rotation Applied", use_container_width=True)
79
+
80
+ def scaling(img):
81
+ sx=2
82
+ sy=2
83
+ tx=0
84
+ ty=0
85
+ sm=np.array([[sx,0,tx],[0,sy,ty]],dtype=np.float32)
86
+ s_img=cv2.warpAffine(img,sm,(img.shape[1],img.shape[0]))
87
+ img_scal_rgb=cv2.cvtColor(s_img,cv2.COLOR_BGR2RGB)
88
+ st.image(img_scal_rgb, caption="Scaling Applied", use_container_width=True)
89
+
90
 
91
 
92
  if uploaded_file is not None:
 
104
  rotation(img)
105
  transformation.append("Rotation")
106
  if scal:
107
+ scaling(img)
108
  transformation.append("Scaling")
109
  if shearing:
110
  transformation.append("Shearing")