Harika22 commited on
Commit
3c597a7
·
verified ·
1 Parent(s): e8808fa

Update pages/7_Unstructured_data.py

Browse files
Files changed (1) hide show
  1. pages/7_Unstructured_data.py +37 -2
pages/7_Unstructured_data.py CHANGED
@@ -484,6 +484,7 @@ if file_type == "IMAGE":
484
  tx = 100
485
  ty = 100
486
  t_m = np.array([[1,0,tx],[0,1,ty]],dtype=np.float32)
 
487
  t_img = cv2.warpAffine(img,t_m,(2560,1600),borderMode=cv2.BORDER_CONSTANT,borderValue=(0,0,0))
488
  ## save and display the image
489
  cv2.imshow("org_img",img)
@@ -518,6 +519,7 @@ if file_type == "IMAGE":
518
  import cv2
519
  ## creation of rotation matrix
520
  r_m = cv2.getRotationMatrix2D((800,1280),0,1)
 
521
  r_img = cv2.warpAffine(img,r_m,(2560,1600))
522
  ## save and display the image
523
  cv2.imshow("org_img",img)
@@ -553,14 +555,47 @@ if file_type == "IMAGE":
553
  tx = 0
554
  ty = 0
555
  sc_m = np.array([[sx,0,tx],[0,sy,ty]],dtype=np.float32)
556
- ## save and display the image
557
  scale_img = cv2.warpAffine(img,sc_m,(2560,1600))
 
558
  cv2.imshow("org_img",img)
559
  cv2.imshow("scaled_img",scale_img)
560
  cv2.waitKey()
561
  cv2.destroyAllWindows()
562
  ''')
563
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
564
 
565
 
566
 
 
484
  tx = 100
485
  ty = 100
486
  t_m = np.array([[1,0,tx],[0,1,ty]],dtype=np.float32)
487
+ ## applies the translation affine transformation using warpAffine
488
  t_img = cv2.warpAffine(img,t_m,(2560,1600),borderMode=cv2.BORDER_CONSTANT,borderValue=(0,0,0))
489
  ## save and display the image
490
  cv2.imshow("org_img",img)
 
519
  import cv2
520
  ## creation of rotation matrix
521
  r_m = cv2.getRotationMatrix2D((800,1280),0,1)
522
+ ## applies the rotation affine transformation using warpAffine
523
  r_img = cv2.warpAffine(img,r_m,(2560,1600))
524
  ## save and display the image
525
  cv2.imshow("org_img",img)
 
555
  tx = 0
556
  ty = 0
557
  sc_m = np.array([[sx,0,tx],[0,sy,ty]],dtype=np.float32)
558
+ ## applies the scaling affine transformation using warpAffine
559
  scale_img = cv2.warpAffine(img,sc_m,(2560,1600))
560
+ ## save and display the image
561
  cv2.imshow("org_img",img)
562
  cv2.imshow("scaled_img",scale_img)
563
  cv2.waitKey()
564
  cv2.destroyAllWindows()
565
  ''')
566
+ st.subheader('**Shearing**')
567
+ st.markdown('''
568
+ - Shearing is a affine transformation matrix which is used for expansion on x-axis and y-axis
569
+ - Formula:
570
+ $$
571
+ I(x,y) \cdot Shearing matrix = I'(x',y')
572
+ $$
573
+ - **Shearing matrix:**
574
+ - [1 Shx Tx
575
+
576
+ Shy 1 Ty]
577
+ - Formula:
578
+ $$
579
+ x' = x + shearX \cdot y \\
580
+ y' = y + shearY \cdot x
581
+ $$
582
+ ''')
583
+ st.code('''
584
+ import cv2
585
+ ## creation of shearing matrix
586
+ shx = 0.3
587
+ shy = 1
588
+ tx = 100
589
+ ty = 100
590
+ sh_m = np.array([[1,shx,tx],[shy,1,ty]],dtype=np.float32)
591
+ ## applies the shearing affine transformation using warpAffine
592
+ shear_img = cv2.warpAffine(img,sh_m,(2560,1600))
593
+ ## save and display the image
594
+ cv2.imshow("org_img",img)
595
+ cv2.imshow("shear_img",shear_img)
596
+ cv2.waitKey()
597
+ cv2.destroyAllWindows()
598
+ ''')
599
 
600
 
601