LakshmiHarika commited on
Commit
f344007
·
verified ·
1 Parent(s): 5ad0bc1

Delete Jupyter_Notes

Browse files
Jupyter_Notes/images_page_2.html DELETED
The diff for this file is too large to render. See raw diff
 
Jupyter_Notes/images_page_2.ipynb DELETED
@@ -1,312 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": 1,
6
- "id": "993a08d6-a5eb-4a28-8225-d50103d116a5",
7
- "metadata": {},
8
- "outputs": [
9
- {
10
- "name": "stdout",
11
- "output_type": "stream",
12
- "text": [
13
- "Requirement already satisfied: opencv-python in c:\\users\\laksh\\anaconda3\\lib\\site-packages (4.10.0.84)\n",
14
- "Requirement already satisfied: numpy>=1.21.2 in c:\\users\\laksh\\anaconda3\\lib\\site-packages (from opencv-python) (1.26.4)\n",
15
- "Note: you may need to restart the kernel to use updated packages.\n"
16
- ]
17
- }
18
- ],
19
- "source": [
20
- "pip install opencv-python"
21
- ]
22
- },
23
- {
24
- "cell_type": "code",
25
- "execution_count": 3,
26
- "id": "3938dd1a-aa2e-41c4-849f-d7a9c063650b",
27
- "metadata": {},
28
- "outputs": [
29
- {
30
- "name": "stdout",
31
- "output_type": "stream",
32
- "text": [
33
- "4.10.0\n"
34
- ]
35
- }
36
- ],
37
- "source": [
38
- "import cv2\n",
39
- "print(cv2.__version__) # This will display the installed OpenCV version"
40
- ]
41
- },
42
- {
43
- "cell_type": "markdown",
44
- "id": "b3f9476e-c1e5-4a28-9850-bba69c81575e",
45
- "metadata": {},
46
- "source": [
47
- "### Reading and Converting Image to array using imread()"
48
- ]
49
- },
50
- {
51
- "cell_type": "code",
52
- "execution_count": 28,
53
- "id": "eb59dd6a-4b16-4160-8a97-4cddd762e615",
54
- "metadata": {},
55
- "outputs": [],
56
- "source": [
57
- "img = cv2.imread(r\"C:\\Users\\laksh\\Downloads\\mickey_mouse.jpeg\") # by default it will give 3d-array"
58
- ]
59
- },
60
- {
61
- "cell_type": "code",
62
- "execution_count": 30,
63
- "id": "682f8850-d44d-4540-9708-ad6fae826323",
64
- "metadata": {},
65
- "outputs": [
66
- {
67
- "data": {
68
- "text/plain": [
69
- "array([[[221, 210, 206],\n",
70
- " [255, 255, 251],\n",
71
- " [253, 255, 254],\n",
72
- " ...,\n",
73
- " [252, 255, 251],\n",
74
- " [255, 255, 249],\n",
75
- " [219, 209, 215]],\n",
76
- "\n",
77
- " [[219, 212, 209],\n",
78
- " [254, 252, 251],\n",
79
- " [247, 255, 255],\n",
80
- " ...,\n",
81
- " [251, 255, 255],\n",
82
- " [255, 253, 248],\n",
83
- " [215, 208, 211]],\n",
84
- "\n",
85
- " [[211, 213, 213],\n",
86
- " [245, 252, 255],\n",
87
- " [239, 254, 255],\n",
88
- " ...,\n",
89
- " [244, 255, 255],\n",
90
- " [252, 255, 253],\n",
91
- " [213, 208, 210]],\n",
92
- "\n",
93
- " ...,\n",
94
- "\n",
95
- " [[207, 211, 200],\n",
96
- " [252, 255, 250],\n",
97
- " [248, 255, 255],\n",
98
- " ...,\n",
99
- " [245, 254, 255],\n",
100
- " [247, 254, 251],\n",
101
- " [212, 214, 214]],\n",
102
- "\n",
103
- " [[219, 220, 216],\n",
104
- " [243, 246, 244],\n",
105
- " [248, 254, 253],\n",
106
- " ...,\n",
107
- " [251, 255, 255],\n",
108
- " [245, 249, 244],\n",
109
- " [214, 216, 216]],\n",
110
- "\n",
111
- " [[238, 239, 237],\n",
112
- " [232, 235, 233],\n",
113
- " [224, 228, 229],\n",
114
- " ...,\n",
115
- " [227, 228, 226],\n",
116
- " [233, 234, 230],\n",
117
- " [244, 246, 246]]], dtype=uint8)"
118
- ]
119
- },
120
- "execution_count": 30,
121
- "metadata": {},
122
- "output_type": "execute_result"
123
- }
124
- ],
125
- "source": [
126
- "img"
127
- ]
128
- },
129
- {
130
- "cell_type": "code",
131
- "execution_count": 32,
132
- "id": "0b5d38d6-0535-4d07-8c3b-af89b7ebbb93",
133
- "metadata": {},
134
- "outputs": [
135
- {
136
- "data": {
137
- "text/plain": [
138
- "(732, 551, 3)"
139
- ]
140
- },
141
- "execution_count": 32,
142
- "metadata": {},
143
- "output_type": "execute_result"
144
- }
145
- ],
146
- "source": [
147
- "img.shape"
148
- ]
149
- },
150
- {
151
- "cell_type": "code",
152
- "execution_count": 34,
153
- "id": "9dbec1f6-7141-4900-80dc-16ca8e13c0c4",
154
- "metadata": {},
155
- "outputs": [
156
- {
157
- "data": {
158
- "text/plain": [
159
- "dtype('uint8')"
160
- ]
161
- },
162
- "execution_count": 34,
163
- "metadata": {},
164
- "output_type": "execute_result"
165
- }
166
- ],
167
- "source": [
168
- "img.dtype"
169
- ]
170
- },
171
- {
172
- "cell_type": "code",
173
- "execution_count": 36,
174
- "id": "9da3dac3-40b7-4287-83ad-0d0d77fa962d",
175
- "metadata": {},
176
- "outputs": [],
177
- "source": [
178
- "img1 = cv2.imread(r\"P:\\IMG_5723.JPG\",flags = 0) # using flags = 0 we can convert it into 2d-array"
179
- ]
180
- },
181
- {
182
- "cell_type": "code",
183
- "execution_count": 38,
184
- "id": "d4fc6f2f-c8e1-4240-ab4e-eaf1bdfb8ae7",
185
- "metadata": {},
186
- "outputs": [
187
- {
188
- "data": {
189
- "text/plain": [
190
- "(4032, 3024)"
191
- ]
192
- },
193
- "execution_count": 38,
194
- "metadata": {},
195
- "output_type": "execute_result"
196
- }
197
- ],
198
- "source": [
199
- "img1.shape"
200
- ]
201
- },
202
- {
203
- "cell_type": "code",
204
- "execution_count": 40,
205
- "id": "8e006b49-1fd7-4494-a074-53dfef43e933",
206
- "metadata": {},
207
- "outputs": [
208
- {
209
- "data": {
210
- "text/plain": [
211
- "array([[183, 183, 182, ..., 186, 186, 186],\n",
212
- " [182, 182, 182, ..., 186, 186, 186],\n",
213
- " [181, 181, 181, ..., 185, 185, 185],\n",
214
- " ...,\n",
215
- " [ 54, 57, 59, ..., 104, 96, 92],\n",
216
- " [ 56, 60, 63, ..., 109, 104, 99],\n",
217
- " [ 53, 58, 64, ..., 114, 109, 102]], dtype=uint8)"
218
- ]
219
- },
220
- "execution_count": 40,
221
- "metadata": {},
222
- "output_type": "execute_result"
223
- }
224
- ],
225
- "source": [
226
- "img1"
227
- ]
228
- },
229
- {
230
- "cell_type": "code",
231
- "execution_count": 42,
232
- "id": "d2b36743-dea0-4243-bae5-52a012a43c1b",
233
- "metadata": {},
234
- "outputs": [],
235
- "source": [
236
- "### Displaying the Images"
237
- ]
238
- },
239
- {
240
- "cell_type": "code",
241
- "execution_count": 44,
242
- "id": "2533d99d-4ada-402c-b2f9-b0301ac01ae2",
243
- "metadata": {},
244
- "outputs": [],
245
- "source": [
246
- "cv2.imshow(\"White\",img)\n",
247
- "\n",
248
- "cv2.waitKey(0) # 0 and no values means infinite delay to close X button\n",
249
- "\n",
250
- "cv2.destroyAllWindows()"
251
- ]
252
- },
253
- {
254
- "cell_type": "markdown",
255
- "id": "69f195df-1baa-4848-a63d-be90dd0ee676",
256
- "metadata": {},
257
- "source": [
258
- "### Saving an Image"
259
- ]
260
- },
261
- {
262
- "cell_type": "code",
263
- "execution_count": 47,
264
- "id": "dac06ce8-ef18-42e5-8e87-d6a948d3387a",
265
- "metadata": {},
266
- "outputs": [
267
- {
268
- "data": {
269
- "text/plain": [
270
- "True"
271
- ]
272
- },
273
- "execution_count": 47,
274
- "metadata": {},
275
- "output_type": "execute_result"
276
- }
277
- ],
278
- "source": [
279
- "cv2.imwrite(r\"H:\\innomatics\\ML\\ML Class\\white_Img.jpg\",img)"
280
- ]
281
- },
282
- {
283
- "cell_type": "code",
284
- "execution_count": null,
285
- "id": "29690e46-6202-4ff5-8e53-7993c5bb61e6",
286
- "metadata": {},
287
- "outputs": [],
288
- "source": []
289
- }
290
- ],
291
- "metadata": {
292
- "kernelspec": {
293
- "display_name": "Python 3 (ipykernel)",
294
- "language": "python",
295
- "name": "python3"
296
- },
297
- "language_info": {
298
- "codemirror_mode": {
299
- "name": "ipython",
300
- "version": 3
301
- },
302
- "file_extension": ".py",
303
- "mimetype": "text/x-python",
304
- "name": "python",
305
- "nbconvert_exporter": "python",
306
- "pygments_lexer": "ipython3",
307
- "version": "3.12.7"
308
- }
309
- },
310
- "nbformat": 4,
311
- "nbformat_minor": 5
312
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Jupyter_Notes/images_page_3.ipynb DELETED
@@ -1,317 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": 1,
6
- "id": "8ded0138-8e45-4a67-a25c-c47eeda71e97",
7
- "metadata": {},
8
- "outputs": [],
9
- "source": [
10
- "import cv2\n",
11
- "import numpy as np"
12
- ]
13
- },
14
- {
15
- "cell_type": "markdown",
16
- "id": "42d75506-dffc-48f5-9824-6fb53daddb27",
17
- "metadata": {},
18
- "source": [
19
- "### creating black and white Images in 2d array --- Gray scale color space"
20
- ]
21
- },
22
- {
23
- "cell_type": "code",
24
- "execution_count": 4,
25
- "id": "3bb9760b-8001-48fa-ad8a-2273ded579c9",
26
- "metadata": {},
27
- "outputs": [],
28
- "source": [
29
- "white_img = np.full((500,500),255,dtype = np.uint8)\n",
30
- "black_img = np.zeros((500,500),dtype = np.uint8)"
31
- ]
32
- },
33
- {
34
- "cell_type": "code",
35
- "execution_count": 6,
36
- "id": "9407730f-d563-412b-bcd3-8d8e85d465b9",
37
- "metadata": {},
38
- "outputs": [],
39
- "source": [
40
- "cv2.imshow(\"White\",white_img)\n",
41
- "cv2.imshow(\"Black\",black_img)\n",
42
- "\n",
43
- "cv2.waitKey(0) # 0 and no values means infinite delay to close X button\n",
44
- "\n",
45
- "cv2.destroyAllWindows()"
46
- ]
47
- },
48
- {
49
- "cell_type": "markdown",
50
- "id": "f1ff81c9-23f9-4c73-9b91-7d07fa6dc5cf",
51
- "metadata": {},
52
- "source": [
53
- "### creating Gray-scale Images in 2d array --- Gray scale color space"
54
- ]
55
- },
56
- {
57
- "cell_type": "code",
58
- "execution_count": 9,
59
- "id": "6a94f960-8c92-4a3e-85d5-9cfaff6027a9",
60
- "metadata": {},
61
- "outputs": [],
62
- "source": [
63
- "gray1_img = np.full((500,500),55,dtype = np.uint8)\n",
64
- "gray2_img = np.full((500,500),155,dtype = np.uint8)"
65
- ]
66
- },
67
- {
68
- "cell_type": "code",
69
- "execution_count": 11,
70
- "id": "bdb0452a-d756-4dc6-bec9-91d5573fcee6",
71
- "metadata": {},
72
- "outputs": [],
73
- "source": [
74
- "cv2.imshow(\"gray1\",gray1_img)\n",
75
- "cv2.imshow(\"gray2\",gray2_img)\n",
76
- "\n",
77
- "cv2.waitKey(0)\n",
78
- "\n",
79
- "cv2.destroyAllWindows()"
80
- ]
81
- },
82
- {
83
- "cell_type": "markdown",
84
- "id": "7b37b480-6a61-4a82-8f55-11e3c634c346",
85
- "metadata": {},
86
- "source": [
87
- "### Creating rgb Image by creating three channels and merging those channels"
88
- ]
89
- },
90
- {
91
- "cell_type": "code",
92
- "execution_count": 14,
93
- "id": "db62b81b-45b6-493c-bd9d-8873ee3c0c9f",
94
- "metadata": {},
95
- "outputs": [],
96
- "source": [
97
- "# creating images\n",
98
- "\n",
99
- "b = np.full((300,300),255,dtype = np.uint8)\n",
100
- "g = np.zeros((300,300),dtype = np.uint8)\n",
101
- "r = np.zeros((300,300),dtype = np.uint8)"
102
- ]
103
- },
104
- {
105
- "cell_type": "code",
106
- "execution_count": 16,
107
- "id": "016a110a-237e-4448-af59-72506e0638d4",
108
- "metadata": {},
109
- "outputs": [],
110
- "source": [
111
- "#Merging all images to get rgb image\n",
112
- "\n",
113
- "b_img = cv2.merge([b,g,r])\n",
114
- "g_img = cv2.merge([g,b,r])\n",
115
- "r_img = cv2.merge([r,g,b])"
116
- ]
117
- },
118
- {
119
- "cell_type": "code",
120
- "execution_count": 18,
121
- "id": "226d1940-e94e-4d9c-9673-c4b0bfa650b7",
122
- "metadata": {},
123
- "outputs": [],
124
- "source": [
125
- "# Dispalying the Image\n",
126
- "\n",
127
- "cv2.imshow(\"Blue\",b_img)\n",
128
- "cv2.imshow(\"Green\",g_img)\n",
129
- "cv2.imshow(\"Red\",r_img)\n",
130
- "\n",
131
- "cv2.waitKey(0)\n",
132
- "\n",
133
- "cv2.destroyAllWindows()"
134
- ]
135
- },
136
- {
137
- "cell_type": "markdown",
138
- "id": "3e0cd1b1-8061-42ab-a9b1-8cfed67b4c14",
139
- "metadata": {},
140
- "source": [
141
- "### Splitting an RGB Image into red,blue and green channels"
142
- ]
143
- },
144
- {
145
- "cell_type": "code",
146
- "execution_count": 23,
147
- "id": "624fca87-a42b-4bc8-b7cc-fae9ca7d9809",
148
- "metadata": {},
149
- "outputs": [],
150
- "source": [
151
- "img = cv2.imread(r\"C:\\Users\\laksh\\Downloads\\mickey_mouse.jpeg\") # reading Image"
152
- ]
153
- },
154
- {
155
- "cell_type": "code",
156
- "execution_count": 25,
157
- "id": "be66eb3c-9281-4049-89f9-d25734660e22",
158
- "metadata": {},
159
- "outputs": [],
160
- "source": [
161
- "b,g,r = cv2.split(img) # splitting into three channels"
162
- ]
163
- },
164
- {
165
- "cell_type": "code",
166
- "execution_count": 27,
167
- "id": "3f7a1355-499e-41c5-bb1b-6df0302144b1",
168
- "metadata": {},
169
- "outputs": [],
170
- "source": [
171
- "zeros = np.zeros(img.shape[:-1],dtype = np.uint8)"
172
- ]
173
- },
174
- {
175
- "cell_type": "code",
176
- "execution_count": 29,
177
- "id": "423544d7-6e79-4e2f-a06b-d126e6bcde17",
178
- "metadata": {},
179
- "outputs": [],
180
- "source": [
181
- "blue_channel = cv2.merge([b,zeros,zeros])\n",
182
- "green_channel = cv2.merge([zeros,g,zeros])\n",
183
- "red_channel = cv2.merge([zeros,zeros,r])"
184
- ]
185
- },
186
- {
187
- "cell_type": "code",
188
- "execution_count": 31,
189
- "id": "d5582183-6691-46da-9b29-2654da2f796b",
190
- "metadata": {},
191
- "outputs": [],
192
- "source": [
193
- "cv2.imshow(\"Blue_channel\",blue_channel)\n",
194
- "cv2.imshow(\"Green_channel\",green_channel)\n",
195
- "cv2.imshow(\"Red_channel\",red_channel)\n",
196
- "cv2.imshow(\"Original_img\", cv2.merge([b,g,r]))\n",
197
- "\n",
198
- "cv2.waitKey(0)\n",
199
- "\n",
200
- "cv2.destroyAllWindows()"
201
- ]
202
- },
203
- {
204
- "cell_type": "markdown",
205
- "id": "ad020dc8-41f7-45c2-9097-1c32aff47579",
206
- "metadata": {},
207
- "source": [
208
- "### Converting Image to color Spaces"
209
- ]
210
- },
211
- {
212
- "cell_type": "code",
213
- "execution_count": 34,
214
- "id": "044cf632-626f-4765-95a4-07eecad62096",
215
- "metadata": {},
216
- "outputs": [],
217
- "source": [
218
- "img = cv2.imread(r\"C:\\Users\\laksh\\Downloads\\mickey_mouse.jpeg\") # reading Image"
219
- ]
220
- },
221
- {
222
- "cell_type": "code",
223
- "execution_count": 38,
224
- "id": "4645b06d-6e6f-4790-8e2b-f615a8c007c0",
225
- "metadata": {},
226
- "outputs": [
227
- {
228
- "data": {
229
- "text/plain": [
230
- "array([[210, 254, 254, ..., 253, 253, 212],\n",
231
- " [212, 252, 254, ..., 255, 252, 210],\n",
232
- " [213, 252, 253, ..., 254, 254, 209],\n",
233
- " ...,\n",
234
- " [207, 253, 254, ..., 253, 252, 214],\n",
235
- " [219, 245, 253, ..., 255, 247, 216],\n",
236
- " [238, 234, 228, ..., 227, 233, 246]], dtype=uint8)"
237
- ]
238
- },
239
- "execution_count": 38,
240
- "metadata": {},
241
- "output_type": "execute_result"
242
- }
243
- ],
244
- "source": [
245
- "gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)\n",
246
- "gray_img"
247
- ]
248
- },
249
- {
250
- "cell_type": "code",
251
- "execution_count": 40,
252
- "id": "54112f92-06fc-422a-bc54-b7dfe8119fe7",
253
- "metadata": {},
254
- "outputs": [],
255
- "source": [
256
- "cv2.imshow(\"gray_scale_img\",gray_img)\n",
257
- "\n",
258
- "cv2.waitKey(0)\n",
259
- "\n",
260
- "cv2.destroyAllWindows()"
261
- ]
262
- },
263
- {
264
- "cell_type": "code",
265
- "execution_count": null,
266
- "id": "d50754b0-32d2-4682-97ea-b34445cb3d60",
267
- "metadata": {},
268
- "outputs": [],
269
- "source": []
270
- },
271
- {
272
- "cell_type": "code",
273
- "execution_count": null,
274
- "id": "04752c4d-1cb0-48a7-b413-d681afeab2b5",
275
- "metadata": {},
276
- "outputs": [],
277
- "source": []
278
- },
279
- {
280
- "cell_type": "code",
281
- "execution_count": null,
282
- "id": "678cb559-e266-4018-a7bf-14fbc6b3d431",
283
- "metadata": {},
284
- "outputs": [],
285
- "source": []
286
- },
287
- {
288
- "cell_type": "code",
289
- "execution_count": null,
290
- "id": "83b6071a-8b63-469f-89de-145678bec93d",
291
- "metadata": {},
292
- "outputs": [],
293
- "source": []
294
- }
295
- ],
296
- "metadata": {
297
- "kernelspec": {
298
- "display_name": "Python 3 (ipykernel)",
299
- "language": "python",
300
- "name": "python3"
301
- },
302
- "language_info": {
303
- "codemirror_mode": {
304
- "name": "ipython",
305
- "version": 3
306
- },
307
- "file_extension": ".py",
308
- "mimetype": "text/x-python",
309
- "name": "python",
310
- "nbconvert_exporter": "python",
311
- "pygments_lexer": "ipython3",
312
- "version": "3.12.7"
313
- }
314
- },
315
- "nbformat": 4,
316
- "nbformat_minor": 5
317
- }