Spaces:
Sleeping
Sleeping
Update pages/7_Unstructured_data.py
Browse files- pages/7_Unstructured_data.py +24 -2
pages/7_Unstructured_data.py
CHANGED
|
@@ -440,13 +440,24 @@ if file_type == "IMAGE":
|
|
| 440 |
- I'(x',y') ---> augumented image
|
| 441 |
$$
|
| 442 |
''', unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 443 |
st.subheader('**Translation**')
|
| 444 |
st.markdown('''
|
| 445 |
- Translation is a type of affine transformation matrix used to shift the image
|
| 446 |
- It shifts the image both in x-axis direction and y-axis direction
|
|
|
|
| 447 |
- Formula:
|
| 448 |
$$
|
| 449 |
-
I(x,y) \cdot Translation matrix = I'(x',y') \\
|
| 450 |
x' = x + t_x \\
|
| 451 |
y' = y + t_y
|
| 452 |
$$
|
|
@@ -480,9 +491,9 @@ if file_type == "IMAGE":
|
|
| 480 |
st.subheader('**Rotation**')
|
| 481 |
st.markdown('''
|
| 482 |
- Rotation is a affine transformation matrix which rotates the image at one angle
|
|
|
|
| 483 |
- Formula:
|
| 484 |
$$
|
| 485 |
-
I(x,y) \cdot Rotation matrix = I'(x',y') \\
|
| 486 |
x' = x \cdot \cos(θ) - y \cdot \sin(θ) \\
|
| 487 |
y' = x \cdot \sin(θ) + y \cdot \cos(θ)
|
| 488 |
$$
|
|
@@ -492,6 +503,17 @@ if file_type == "IMAGE":
|
|
| 492 |
- cos(θ) is anti-clockwise
|
| 493 |
- Angle is between choosen pixel values
|
| 494 |
''')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 495 |
|
| 496 |
|
| 497 |
|
|
|
|
| 440 |
- I'(x',y') ---> augumented image
|
| 441 |
$$
|
| 442 |
''', unsafe_allow_html=True)
|
| 443 |
+
|
| 444 |
+
st.subheader("Affine Transformation Workflow")
|
| 445 |
+
st.markdown("""
|
| 446 |
+
The general steps for performing affine transformation in OpenCV:
|
| 447 |
+
1. Load the Image
|
| 448 |
+
2. Define Source and Destination Points
|
| 449 |
+
3. Calculate the Transformation Matrix
|
| 450 |
+
4. Apply `cv2.warpAffine()`
|
| 451 |
+
5. Display or Save the Transformed Image
|
| 452 |
+
""", unsafe_allow_html=True)
|
| 453 |
+
|
| 454 |
st.subheader('**Translation**')
|
| 455 |
st.markdown('''
|
| 456 |
- Translation is a type of affine transformation matrix used to shift the image
|
| 457 |
- It shifts the image both in x-axis direction and y-axis direction
|
| 458 |
+
- I(x,y) \cdot Translation matrix = I'(x',y')
|
| 459 |
- Formula:
|
| 460 |
$$
|
|
|
|
| 461 |
x' = x + t_x \\
|
| 462 |
y' = y + t_y
|
| 463 |
$$
|
|
|
|
| 491 |
st.subheader('**Rotation**')
|
| 492 |
st.markdown('''
|
| 493 |
- Rotation is a affine transformation matrix which rotates the image at one angle
|
| 494 |
+
- I(x,y) \cdot Rotation matrix = I'(x',y')
|
| 495 |
- Formula:
|
| 496 |
$$
|
|
|
|
| 497 |
x' = x \cdot \cos(θ) - y \cdot \sin(θ) \\
|
| 498 |
y' = x \cdot \sin(θ) + y \cdot \cos(θ)
|
| 499 |
$$
|
|
|
|
| 503 |
- cos(θ) is anti-clockwise
|
| 504 |
- Angle is between choosen pixel values
|
| 505 |
''')
|
| 506 |
+
st.code('''
|
| 507 |
+
import cv2
|
| 508 |
+
## creation of rotation matrix
|
| 509 |
+
r_m = cv2.getRotationMatrix2D((800,1280),0,1)
|
| 510 |
+
r_img = cv2.warpAffine(img,r_m,(2560,1600))
|
| 511 |
+
## save and display the image
|
| 512 |
+
cv2.imshow("org_img",img)
|
| 513 |
+
cv2.imshow("rotated_img",r_img)
|
| 514 |
+
cv2.waitKey()
|
| 515 |
+
cv2.destroyAllWindows()
|
| 516 |
+
''')
|
| 517 |
|
| 518 |
|
| 519 |
|