Skip to content

Commit f204ef9

Browse files
committed
Image manipulation
1 parent 9862945 commit f204ef9

File tree

4 files changed

+104
-510
lines changed

4 files changed

+104
-510
lines changed

Create.ipynb

Lines changed: 0 additions & 234 deletions
This file was deleted.

Image_manipulation_1.ipynb

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Translation"
8+
]
9+
},
10+
{
11+
"cell_type": "code",
12+
"execution_count": 5,
13+
"metadata": {},
14+
"outputs": [],
15+
"source": [
16+
"import cv2\n",
17+
"import numpy as np\n",
18+
"\n",
19+
"pic = cv2.imread(\"cvimg.jpg\")\n",
20+
"\n",
21+
"height,width = pic.shape[:2]\n",
22+
"tx,ty = height/4,width/4\n",
23+
"\n",
24+
"T = np.float32([[1,0,tx],[0,1,ty]])\n",
25+
"\n",
26+
"translate_pic = cv2.warpAffine(pic,T,(width,height))\n",
27+
"cv2.imshow(\"Translation\",translate_pic)\n",
28+
"cv2.waitKey(0)\n",
29+
"cv2.destroyAllWindows()"
30+
]
31+
},
32+
{
33+
"cell_type": "markdown",
34+
"metadata": {},
35+
"source": [
36+
"# Rotation"
37+
]
38+
},
39+
{
40+
"cell_type": "code",
41+
"execution_count": 7,
42+
"metadata": {},
43+
"outputs": [],
44+
"source": [
45+
"import cv2\n",
46+
"import numpy as np\n",
47+
"\n",
48+
"pic = cv2.imread(\"cvimg.jpg\")\n",
49+
"\n",
50+
"height,width = pic.shape[:2]\n",
51+
"center_x,center_y = height/2,width/2\n",
52+
"\n",
53+
"R = cv2.getRotationMatrix2D((center_x,center_y),45,1)\n",
54+
"rotated_pic = cv2.warpAffine(pic,R,(width,height))\n",
55+
"\n",
56+
"cv2.imshow(\"Rotation\",rotated_pic)\n",
57+
"cv2.waitKey(0)\n",
58+
"cv2.destroyAllWindows()"
59+
]
60+
},
61+
{
62+
"cell_type": "code",
63+
"execution_count": 9,
64+
"metadata": {},
65+
"outputs": [],
66+
"source": [
67+
"##rotate by 90degree angle\n",
68+
"rm = cv2.transpose(pic)\n",
69+
"\n",
70+
"cv2.imshow(\"Transpose-Rotation\",rm)\n",
71+
"cv2.waitKey(0)\n",
72+
"cv2.destroyAllWindows()"
73+
]
74+
},
75+
{
76+
"cell_type": "code",
77+
"execution_count": null,
78+
"metadata": {},
79+
"outputs": [],
80+
"source": []
81+
}
82+
],
83+
"metadata": {
84+
"kernelspec": {
85+
"display_name": "Python 3",
86+
"language": "python",
87+
"name": "python3"
88+
},
89+
"language_info": {
90+
"codemirror_mode": {
91+
"name": "ipython",
92+
"version": 3
93+
},
94+
"file_extension": ".py",
95+
"mimetype": "text/x-python",
96+
"name": "python",
97+
"nbconvert_exporter": "python",
98+
"pygments_lexer": "ipython3",
99+
"version": "3.7.6"
100+
}
101+
},
102+
"nbformat": 4,
103+
"nbformat_minor": 4
104+
}

basics_of_opencv.ipynb

Lines changed: 0 additions & 276 deletions
This file was deleted.

cvimg.jpg

26 KB
Loading

0 commit comments

Comments
 (0)