shwetashweta05 commited on
Commit
9674445
1 Parent(s): 8cb4b32

Upload 2 files

Browse files
image_show(b,g,r).ipynb ADDED
@@ -0,0 +1,1109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "id": "461dee1b-62d6-43fc-bbef-42db7566dcbf",
7
+ "metadata": {},
8
+ "outputs": [
9
+ {
10
+ "name": "stdout",
11
+ "output_type": "stream",
12
+ "text": [
13
+ "Requirement already satisfied: kagglehub in c:\\users\\singh\\anaconda3\\lib\\site-packages (0.3.4)\n",
14
+ "Requirement already satisfied: packaging in c:\\users\\singh\\anaconda3\\lib\\site-packages (from kagglehub) (23.1)\n",
15
+ "Requirement already satisfied: requests in c:\\users\\singh\\anaconda3\\lib\\site-packages (from kagglehub) (2.31.0)\n",
16
+ "Requirement already satisfied: tqdm in c:\\users\\singh\\anaconda3\\lib\\site-packages (from kagglehub) (4.65.0)\n",
17
+ "Requirement already satisfied: charset-normalizer<4,>=2 in c:\\users\\singh\\anaconda3\\lib\\site-packages (from requests->kagglehub) (2.0.4)\n",
18
+ "Requirement already satisfied: idna<4,>=2.5 in c:\\users\\singh\\anaconda3\\lib\\site-packages (from requests->kagglehub) (3.4)\n",
19
+ "Requirement already satisfied: urllib3<3,>=1.21.1 in c:\\users\\singh\\anaconda3\\lib\\site-packages (from requests->kagglehub) (2.0.7)\n",
20
+ "Requirement already satisfied: certifi>=2017.4.17 in c:\\users\\singh\\anaconda3\\lib\\site-packages (from requests->kagglehub) (2024.2.2)\n",
21
+ "Requirement already satisfied: colorama in c:\\users\\singh\\anaconda3\\lib\\site-packages (from tqdm->kagglehub) (0.4.6)\n",
22
+ "Note: you may need to restart the kernel to use updated packages.\n"
23
+ ]
24
+ }
25
+ ],
26
+ "source": [
27
+ "pip install kagglehub"
28
+ ]
29
+ },
30
+ {
31
+ "cell_type": "code",
32
+ "execution_count": 9,
33
+ "id": "c3c7d28b-6d74-42d4-9d78-9f964e4b77ef",
34
+ "metadata": {},
35
+ "outputs": [],
36
+ "source": [
37
+ "import kagglehub"
38
+ ]
39
+ },
40
+ {
41
+ "cell_type": "code",
42
+ "execution_count": 10,
43
+ "id": "81c6b0c6-86ba-47b5-bc64-36cb1d679f2f",
44
+ "metadata": {},
45
+ "outputs": [
46
+ {
47
+ "name": "stdout",
48
+ "output_type": "stream",
49
+ "text": [
50
+ "Warning: Looks like you're using an outdated `kagglehub` version, please consider updating (latest version: 0.3.6)\n"
51
+ ]
52
+ }
53
+ ],
54
+ "source": [
55
+ "path=kagglehub.dataset_download(\"rahmasleam/flowers-dataset\")"
56
+ ]
57
+ },
58
+ {
59
+ "cell_type": "code",
60
+ "execution_count": 11,
61
+ "id": "691fb5cf-aeb1-4fe1-ac65-a0de6b1a66a4",
62
+ "metadata": {},
63
+ "outputs": [
64
+ {
65
+ "data": {
66
+ "text/plain": [
67
+ "'C:\\\\Users\\\\Singh\\\\.cache\\\\kagglehub\\\\datasets\\\\rahmasleam\\\\flowers-dataset\\\\versions\\\\1'"
68
+ ]
69
+ },
70
+ "execution_count": 11,
71
+ "metadata": {},
72
+ "output_type": "execute_result"
73
+ }
74
+ ],
75
+ "source": [
76
+ "path"
77
+ ]
78
+ },
79
+ {
80
+ "cell_type": "code",
81
+ "execution_count": 12,
82
+ "id": "a7bd6c4b-a1f2-49fe-9d3b-78fe019bdd27",
83
+ "metadata": {},
84
+ "outputs": [],
85
+ "source": [
86
+ "import os\n",
87
+ "import cv2"
88
+ ]
89
+ },
90
+ {
91
+ "cell_type": "code",
92
+ "execution_count": 31,
93
+ "id": "c9b20532-6f16-424d-9c21-c5aa51b538dd",
94
+ "metadata": {},
95
+ "outputs": [],
96
+ "source": [
97
+ "folders=os.listdir(r\"C:\\Users\\Singh\\Downloads\\flower_photos\") # List all folders in the \"flower_photos\" directory."
98
+ ]
99
+ },
100
+ {
101
+ "cell_type": "code",
102
+ "execution_count": 32,
103
+ "id": "bcd17c4d-bb28-445b-bb20-d6c6c7e082bd",
104
+ "metadata": {},
105
+ "outputs": [
106
+ {
107
+ "data": {
108
+ "text/plain": [
109
+ "['daisy', 'dandelion', 'roses', 'sunflowers', 'tulips']"
110
+ ]
111
+ },
112
+ "execution_count": 32,
113
+ "metadata": {},
114
+ "output_type": "execute_result"
115
+ }
116
+ ],
117
+ "source": [
118
+ "folders"
119
+ ]
120
+ },
121
+ {
122
+ "cell_type": "code",
123
+ "execution_count": 33,
124
+ "id": "a8bb7124-8d25-4ab2-b9f7-efc04eda887f",
125
+ "metadata": {},
126
+ "outputs": [],
127
+ "source": [
128
+ "features=[]\n",
129
+ "class_labels=[]\n",
130
+ "for folder in folders:\n",
131
+ " for images in os.listdir(r\"C:\\Users\\Singh\\Downloads\\flower_photos\\{}\".format(folder)):\n",
132
+ " img=cv2.imread(r\"C:\\Users\\Singh\\Downloads\\flower_photos\\{}\\{}\".format(folder,images),0)# array repress\n",
133
+ " img=cv2.resize(img,(50,50))#resizing the image\n",
134
+ " img=img.flatten()#flattening the image\n",
135
+ " features.append(img)# appending each flatten image in list\n",
136
+ " class_labels.append(folder)#appending each class label to list"
137
+ ]
138
+ },
139
+ {
140
+ "cell_type": "code",
141
+ "execution_count": 34,
142
+ "id": "cc21daf6-98bc-4c23-aff3-c25f66b559c4",
143
+ "metadata": {},
144
+ "outputs": [
145
+ {
146
+ "data": {
147
+ "text/plain": [
148
+ "633"
149
+ ]
150
+ },
151
+ "execution_count": 34,
152
+ "metadata": {},
153
+ "output_type": "execute_result"
154
+ }
155
+ ],
156
+ "source": [
157
+ "len(os.listdir(r\"C:\\Users\\Singh\\Downloads\\flower_photos\\daisy\")) # Count the number of images in the \"daisy\" folder inside \"flower_photos.\""
158
+ ]
159
+ },
160
+ {
161
+ "cell_type": "code",
162
+ "execution_count": 35,
163
+ "id": "cfe72f36-3a96-43ef-a7c8-68b9fa5a5ef5",
164
+ "metadata": {},
165
+ "outputs": [],
166
+ "source": [
167
+ "img1=cv2.imread(r\"C:\\Users\\Singh\\Downloads\\flower_photos\\daisy\\5547758_eea9edfd54_n.jpg\",0) # Load an image from the \"daisy\" folder in grayscale mode (0 indicates grayscale)."
168
+ ]
169
+ },
170
+ {
171
+ "cell_type": "code",
172
+ "execution_count": 36,
173
+ "id": "72e3d4b8-dd96-432a-a88a-48edccb7d999",
174
+ "metadata": {},
175
+ "outputs": [
176
+ {
177
+ "data": {
178
+ "text/plain": [
179
+ "array([[112, 106, 102, ..., 48, 50, 52],\n",
180
+ " [128, 121, 117, ..., 49, 50, 52],\n",
181
+ " [136, 129, 124, ..., 51, 51, 53],\n",
182
+ " ...,\n",
183
+ " [250, 251, 252, ..., 21, 20, 19],\n",
184
+ " [248, 250, 250, ..., 23, 22, 21],\n",
185
+ " [251, 252, 249, ..., 25, 25, 24]], dtype=uint8)"
186
+ ]
187
+ },
188
+ "execution_count": 36,
189
+ "metadata": {},
190
+ "output_type": "execute_result"
191
+ }
192
+ ],
193
+ "source": [
194
+ "img1"
195
+ ]
196
+ },
197
+ {
198
+ "cell_type": "code",
199
+ "execution_count": 37,
200
+ "id": "261e6f19-30bc-4e15-9134-3debdcb235f8",
201
+ "metadata": {},
202
+ "outputs": [
203
+ {
204
+ "data": {
205
+ "text/plain": [
206
+ "(232, 320)"
207
+ ]
208
+ },
209
+ "execution_count": 37,
210
+ "metadata": {},
211
+ "output_type": "execute_result"
212
+ }
213
+ ],
214
+ "source": [
215
+ "img1.shape # Get the shape (dimensions) of the grayscale image."
216
+ ]
217
+ },
218
+ {
219
+ "cell_type": "code",
220
+ "execution_count": 38,
221
+ "id": "9227807f-3552-472e-90c1-7ff1a68c07cc",
222
+ "metadata": {},
223
+ "outputs": [
224
+ {
225
+ "data": {
226
+ "text/plain": [
227
+ "3670"
228
+ ]
229
+ },
230
+ "execution_count": 38,
231
+ "metadata": {},
232
+ "output_type": "execute_result"
233
+ }
234
+ ],
235
+ "source": [
236
+ "len(features) # Get the number of features collected so far (assuming `features` is a list or similar)."
237
+ ]
238
+ },
239
+ {
240
+ "cell_type": "code",
241
+ "execution_count": 39,
242
+ "id": "13569c16-3939-4617-bbe8-e69f153cb2fa",
243
+ "metadata": {},
244
+ "outputs": [
245
+ {
246
+ "data": {
247
+ "text/plain": [
248
+ "3670"
249
+ ]
250
+ },
251
+ "execution_count": 39,
252
+ "metadata": {},
253
+ "output_type": "execute_result"
254
+ }
255
+ ],
256
+ "source": [
257
+ "len(class_labels) # Get the number of class labels collected so far (assuming `class_labels` is a list or similar)."
258
+ ]
259
+ },
260
+ {
261
+ "cell_type": "code",
262
+ "execution_count": 42,
263
+ "id": "3615aff7-79ad-472f-86f6-2dbb19db6c87",
264
+ "metadata": {},
265
+ "outputs": [],
266
+ "source": [
267
+ "import pandas as pd"
268
+ ]
269
+ },
270
+ {
271
+ "cell_type": "code",
272
+ "execution_count": 43,
273
+ "id": "526870d5-168a-4dff-b8e1-dbf509ad5cf2",
274
+ "metadata": {},
275
+ "outputs": [],
276
+ "source": [
277
+ "final_data=pd.DataFrame(features) # Convert the `features` list or array into a pandas DataFrame."
278
+ ]
279
+ },
280
+ {
281
+ "cell_type": "code",
282
+ "execution_count": 44,
283
+ "id": "01fb54b7-cbe8-43e6-81e7-40247b42d522",
284
+ "metadata": {},
285
+ "outputs": [
286
+ {
287
+ "data": {
288
+ "text/plain": [
289
+ "(3670, 2500)"
290
+ ]
291
+ },
292
+ "execution_count": 44,
293
+ "metadata": {},
294
+ "output_type": "execute_result"
295
+ }
296
+ ],
297
+ "source": [
298
+ "final_data.shape"
299
+ ]
300
+ },
301
+ {
302
+ "cell_type": "code",
303
+ "execution_count": 45,
304
+ "id": "4b914cdc-da32-4e76-bc5f-41f1899d6320",
305
+ "metadata": {},
306
+ "outputs": [],
307
+ "source": [
308
+ "import numpy as np"
309
+ ]
310
+ },
311
+ {
312
+ "cell_type": "code",
313
+ "execution_count": 46,
314
+ "id": "c8a7ad09-21d0-47c4-b553-00e95bdfc8b3",
315
+ "metadata": {},
316
+ "outputs": [],
317
+ "source": [
318
+ "final_data=final_data.astype(np.uint8) # Convert all data in the DataFrame to `uint8` data type for storage efficiency."
319
+ ]
320
+ },
321
+ {
322
+ "cell_type": "code",
323
+ "execution_count": 47,
324
+ "id": "41441478-1e01-4799-aa77-ca3c51c6be91",
325
+ "metadata": {},
326
+ "outputs": [
327
+ {
328
+ "data": {
329
+ "text/html": [
330
+ "<div>\n",
331
+ "<style scoped>\n",
332
+ " .dataframe tbody tr th:only-of-type {\n",
333
+ " vertical-align: middle;\n",
334
+ " }\n",
335
+ "\n",
336
+ " .dataframe tbody tr th {\n",
337
+ " vertical-align: top;\n",
338
+ " }\n",
339
+ "\n",
340
+ " .dataframe thead th {\n",
341
+ " text-align: right;\n",
342
+ " }\n",
343
+ "</style>\n",
344
+ "<table border=\"1\" class=\"dataframe\">\n",
345
+ " <thead>\n",
346
+ " <tr style=\"text-align: right;\">\n",
347
+ " <th></th>\n",
348
+ " <th>0</th>\n",
349
+ " <th>1</th>\n",
350
+ " <th>2</th>\n",
351
+ " <th>3</th>\n",
352
+ " <th>4</th>\n",
353
+ " <th>5</th>\n",
354
+ " <th>6</th>\n",
355
+ " <th>7</th>\n",
356
+ " <th>8</th>\n",
357
+ " <th>9</th>\n",
358
+ " <th>...</th>\n",
359
+ " <th>2490</th>\n",
360
+ " <th>2491</th>\n",
361
+ " <th>2492</th>\n",
362
+ " <th>2493</th>\n",
363
+ " <th>2494</th>\n",
364
+ " <th>2495</th>\n",
365
+ " <th>2496</th>\n",
366
+ " <th>2497</th>\n",
367
+ " <th>2498</th>\n",
368
+ " <th>2499</th>\n",
369
+ " </tr>\n",
370
+ " </thead>\n",
371
+ " <tbody>\n",
372
+ " <tr>\n",
373
+ " <th>0</th>\n",
374
+ " <td>143</td>\n",
375
+ " <td>149</td>\n",
376
+ " <td>160</td>\n",
377
+ " <td>169</td>\n",
378
+ " <td>167</td>\n",
379
+ " <td>167</td>\n",
380
+ " <td>145</td>\n",
381
+ " <td>144</td>\n",
382
+ " <td>144</td>\n",
383
+ " <td>159</td>\n",
384
+ " <td>...</td>\n",
385
+ " <td>171</td>\n",
386
+ " <td>174</td>\n",
387
+ " <td>168</td>\n",
388
+ " <td>149</td>\n",
389
+ " <td>134</td>\n",
390
+ " <td>128</td>\n",
391
+ " <td>137</td>\n",
392
+ " <td>137</td>\n",
393
+ " <td>131</td>\n",
394
+ " <td>127</td>\n",
395
+ " </tr>\n",
396
+ " <tr>\n",
397
+ " <th>1</th>\n",
398
+ " <td>224</td>\n",
399
+ " <td>222</td>\n",
400
+ " <td>216</td>\n",
401
+ " <td>232</td>\n",
402
+ " <td>228</td>\n",
403
+ " <td>75</td>\n",
404
+ " <td>85</td>\n",
405
+ " <td>80</td>\n",
406
+ " <td>182</td>\n",
407
+ " <td>185</td>\n",
408
+ " <td>...</td>\n",
409
+ " <td>120</td>\n",
410
+ " <td>116</td>\n",
411
+ " <td>107</td>\n",
412
+ " <td>110</td>\n",
413
+ " <td>108</td>\n",
414
+ " <td>156</td>\n",
415
+ " <td>169</td>\n",
416
+ " <td>141</td>\n",
417
+ " <td>125</td>\n",
418
+ " <td>172</td>\n",
419
+ " </tr>\n",
420
+ " <tr>\n",
421
+ " <th>2</th>\n",
422
+ " <td>108</td>\n",
423
+ " <td>81</td>\n",
424
+ " <td>97</td>\n",
425
+ " <td>84</td>\n",
426
+ " <td>102</td>\n",
427
+ " <td>120</td>\n",
428
+ " <td>108</td>\n",
429
+ " <td>106</td>\n",
430
+ " <td>140</td>\n",
431
+ " <td>128</td>\n",
432
+ " <td>...</td>\n",
433
+ " <td>38</td>\n",
434
+ " <td>44</td>\n",
435
+ " <td>27</td>\n",
436
+ " <td>26</td>\n",
437
+ " <td>26</td>\n",
438
+ " <td>27</td>\n",
439
+ " <td>27</td>\n",
440
+ " <td>31</td>\n",
441
+ " <td>36</td>\n",
442
+ " <td>40</td>\n",
443
+ " </tr>\n",
444
+ " <tr>\n",
445
+ " <th>3</th>\n",
446
+ " <td>26</td>\n",
447
+ " <td>25</td>\n",
448
+ " <td>26</td>\n",
449
+ " <td>29</td>\n",
450
+ " <td>32</td>\n",
451
+ " <td>35</td>\n",
452
+ " <td>37</td>\n",
453
+ " <td>38</td>\n",
454
+ " <td>38</td>\n",
455
+ " <td>40</td>\n",
456
+ " <td>...</td>\n",
457
+ " <td>18</td>\n",
458
+ " <td>16</td>\n",
459
+ " <td>15</td>\n",
460
+ " <td>16</td>\n",
461
+ " <td>21</td>\n",
462
+ " <td>18</td>\n",
463
+ " <td>24</td>\n",
464
+ " <td>16</td>\n",
465
+ " <td>20</td>\n",
466
+ " <td>23</td>\n",
467
+ " </tr>\n",
468
+ " <tr>\n",
469
+ " <th>4</th>\n",
470
+ " <td>20</td>\n",
471
+ " <td>21</td>\n",
472
+ " <td>36</td>\n",
473
+ " <td>45</td>\n",
474
+ " <td>46</td>\n",
475
+ " <td>45</td>\n",
476
+ " <td>40</td>\n",
477
+ " <td>42</td>\n",
478
+ " <td>37</td>\n",
479
+ " <td>56</td>\n",
480
+ " <td>...</td>\n",
481
+ " <td>26</td>\n",
482
+ " <td>42</td>\n",
483
+ " <td>48</td>\n",
484
+ " <td>42</td>\n",
485
+ " <td>26</td>\n",
486
+ " <td>25</td>\n",
487
+ " <td>31</td>\n",
488
+ " <td>39</td>\n",
489
+ " <td>27</td>\n",
490
+ " <td>35</td>\n",
491
+ " </tr>\n",
492
+ " <tr>\n",
493
+ " <th>...</th>\n",
494
+ " <td>...</td>\n",
495
+ " <td>...</td>\n",
496
+ " <td>...</td>\n",
497
+ " <td>...</td>\n",
498
+ " <td>...</td>\n",
499
+ " <td>...</td>\n",
500
+ " <td>...</td>\n",
501
+ " <td>...</td>\n",
502
+ " <td>...</td>\n",
503
+ " <td>...</td>\n",
504
+ " <td>...</td>\n",
505
+ " <td>...</td>\n",
506
+ " <td>...</td>\n",
507
+ " <td>...</td>\n",
508
+ " <td>...</td>\n",
509
+ " <td>...</td>\n",
510
+ " <td>...</td>\n",
511
+ " <td>...</td>\n",
512
+ " <td>...</td>\n",
513
+ " <td>...</td>\n",
514
+ " <td>...</td>\n",
515
+ " </tr>\n",
516
+ " <tr>\n",
517
+ " <th>3665</th>\n",
518
+ " <td>212</td>\n",
519
+ " <td>189</td>\n",
520
+ " <td>186</td>\n",
521
+ " <td>212</td>\n",
522
+ " <td>47</td>\n",
523
+ " <td>82</td>\n",
524
+ " <td>116</td>\n",
525
+ " <td>131</td>\n",
526
+ " <td>82</td>\n",
527
+ " <td>79</td>\n",
528
+ " <td>...</td>\n",
529
+ " <td>83</td>\n",
530
+ " <td>103</td>\n",
531
+ " <td>114</td>\n",
532
+ " <td>40</td>\n",
533
+ " <td>7</td>\n",
534
+ " <td>30</td>\n",
535
+ " <td>30</td>\n",
536
+ " <td>86</td>\n",
537
+ " <td>194</td>\n",
538
+ " <td>215</td>\n",
539
+ " </tr>\n",
540
+ " <tr>\n",
541
+ " <th>3666</th>\n",
542
+ " <td>135</td>\n",
543
+ " <td>126</td>\n",
544
+ " <td>129</td>\n",
545
+ " <td>131</td>\n",
546
+ " <td>119</td>\n",
547
+ " <td>141</td>\n",
548
+ " <td>135</td>\n",
549
+ " <td>128</td>\n",
550
+ " <td>132</td>\n",
551
+ " <td>136</td>\n",
552
+ " <td>...</td>\n",
553
+ " <td>48</td>\n",
554
+ " <td>53</td>\n",
555
+ " <td>60</td>\n",
556
+ " <td>58</td>\n",
557
+ " <td>54</td>\n",
558
+ " <td>41</td>\n",
559
+ " <td>48</td>\n",
560
+ " <td>84</td>\n",
561
+ " <td>132</td>\n",
562
+ " <td>120</td>\n",
563
+ " </tr>\n",
564
+ " <tr>\n",
565
+ " <th>3667</th>\n",
566
+ " <td>88</td>\n",
567
+ " <td>72</td>\n",
568
+ " <td>78</td>\n",
569
+ " <td>97</td>\n",
570
+ " <td>57</td>\n",
571
+ " <td>77</td>\n",
572
+ " <td>91</td>\n",
573
+ " <td>79</td>\n",
574
+ " <td>46</td>\n",
575
+ " <td>77</td>\n",
576
+ " <td>...</td>\n",
577
+ " <td>83</td>\n",
578
+ " <td>71</td>\n",
579
+ " <td>81</td>\n",
580
+ " <td>89</td>\n",
581
+ " <td>91</td>\n",
582
+ " <td>91</td>\n",
583
+ " <td>87</td>\n",
584
+ " <td>103</td>\n",
585
+ " <td>80</td>\n",
586
+ " <td>80</td>\n",
587
+ " </tr>\n",
588
+ " <tr>\n",
589
+ " <th>3668</th>\n",
590
+ " <td>157</td>\n",
591
+ " <td>189</td>\n",
592
+ " <td>169</td>\n",
593
+ " <td>132</td>\n",
594
+ " <td>174</td>\n",
595
+ " <td>162</td>\n",
596
+ " <td>185</td>\n",
597
+ " <td>174</td>\n",
598
+ " <td>122</td>\n",
599
+ " <td>160</td>\n",
600
+ " <td>...</td>\n",
601
+ " <td>57</td>\n",
602
+ " <td>152</td>\n",
603
+ " <td>193</td>\n",
604
+ " <td>74</td>\n",
605
+ " <td>23</td>\n",
606
+ " <td>18</td>\n",
607
+ " <td>8</td>\n",
608
+ " <td>12</td>\n",
609
+ " <td>19</td>\n",
610
+ " <td>45</td>\n",
611
+ " </tr>\n",
612
+ " <tr>\n",
613
+ " <th>3669</th>\n",
614
+ " <td>49</td>\n",
615
+ " <td>62</td>\n",
616
+ " <td>118</td>\n",
617
+ " <td>122</td>\n",
618
+ " <td>75</td>\n",
619
+ " <td>164</td>\n",
620
+ " <td>127</td>\n",
621
+ " <td>98</td>\n",
622
+ " <td>74</td>\n",
623
+ " <td>78</td>\n",
624
+ " <td>...</td>\n",
625
+ " <td>98</td>\n",
626
+ " <td>146</td>\n",
627
+ " <td>80</td>\n",
628
+ " <td>45</td>\n",
629
+ " <td>63</td>\n",
630
+ " <td>47</td>\n",
631
+ " <td>91</td>\n",
632
+ " <td>56</td>\n",
633
+ " <td>76</td>\n",
634
+ " <td>57</td>\n",
635
+ " </tr>\n",
636
+ " </tbody>\n",
637
+ "</table>\n",
638
+ "<p>3670 rows × 2500 columns</p>\n",
639
+ "</div>"
640
+ ],
641
+ "text/plain": [
642
+ " 0 1 2 3 4 5 6 7 8 9 ... 2490 \\\n",
643
+ "0 143 149 160 169 167 167 145 144 144 159 ... 171 \n",
644
+ "1 224 222 216 232 228 75 85 80 182 185 ... 120 \n",
645
+ "2 108 81 97 84 102 120 108 106 140 128 ... 38 \n",
646
+ "3 26 25 26 29 32 35 37 38 38 40 ... 18 \n",
647
+ "4 20 21 36 45 46 45 40 42 37 56 ... 26 \n",
648
+ "... ... ... ... ... ... ... ... ... ... ... ... ... \n",
649
+ "3665 212 189 186 212 47 82 116 131 82 79 ... 83 \n",
650
+ "3666 135 126 129 131 119 141 135 128 132 136 ... 48 \n",
651
+ "3667 88 72 78 97 57 77 91 79 46 77 ... 83 \n",
652
+ "3668 157 189 169 132 174 162 185 174 122 160 ... 57 \n",
653
+ "3669 49 62 118 122 75 164 127 98 74 78 ... 98 \n",
654
+ "\n",
655
+ " 2491 2492 2493 2494 2495 2496 2497 2498 2499 \n",
656
+ "0 174 168 149 134 128 137 137 131 127 \n",
657
+ "1 116 107 110 108 156 169 141 125 172 \n",
658
+ "2 44 27 26 26 27 27 31 36 40 \n",
659
+ "3 16 15 16 21 18 24 16 20 23 \n",
660
+ "4 42 48 42 26 25 31 39 27 35 \n",
661
+ "... ... ... ... ... ... ... ... ... ... \n",
662
+ "3665 103 114 40 7 30 30 86 194 215 \n",
663
+ "3666 53 60 58 54 41 48 84 132 120 \n",
664
+ "3667 71 81 89 91 91 87 103 80 80 \n",
665
+ "3668 152 193 74 23 18 8 12 19 45 \n",
666
+ "3669 146 80 45 63 47 91 56 76 57 \n",
667
+ "\n",
668
+ "[3670 rows x 2500 columns]"
669
+ ]
670
+ },
671
+ "execution_count": 47,
672
+ "metadata": {},
673
+ "output_type": "execute_result"
674
+ }
675
+ ],
676
+ "source": [
677
+ "final_data "
678
+ ]
679
+ },
680
+ {
681
+ "cell_type": "code",
682
+ "execution_count": 48,
683
+ "id": "b1f089c9-df2f-4d7c-b3ba-a3ef75d22256",
684
+ "metadata": {},
685
+ "outputs": [],
686
+ "source": [
687
+ "final_data[\"class_labels\"]=class_labels # Add a new column \"class_labels\" to the DataFrame with the collected class labels."
688
+ ]
689
+ },
690
+ {
691
+ "cell_type": "code",
692
+ "execution_count": 49,
693
+ "id": "583cecc9-cb99-4bc9-93e5-ab67de226bd3",
694
+ "metadata": {},
695
+ "outputs": [
696
+ {
697
+ "data": {
698
+ "text/html": [
699
+ "<div>\n",
700
+ "<style scoped>\n",
701
+ " .dataframe tbody tr th:only-of-type {\n",
702
+ " vertical-align: middle;\n",
703
+ " }\n",
704
+ "\n",
705
+ " .dataframe tbody tr th {\n",
706
+ " vertical-align: top;\n",
707
+ " }\n",
708
+ "\n",
709
+ " .dataframe thead th {\n",
710
+ " text-align: right;\n",
711
+ " }\n",
712
+ "</style>\n",
713
+ "<table border=\"1\" class=\"dataframe\">\n",
714
+ " <thead>\n",
715
+ " <tr style=\"text-align: right;\">\n",
716
+ " <th></th>\n",
717
+ " <th>0</th>\n",
718
+ " <th>1</th>\n",
719
+ " <th>2</th>\n",
720
+ " <th>3</th>\n",
721
+ " <th>4</th>\n",
722
+ " <th>5</th>\n",
723
+ " <th>6</th>\n",
724
+ " <th>7</th>\n",
725
+ " <th>8</th>\n",
726
+ " <th>9</th>\n",
727
+ " <th>...</th>\n",
728
+ " <th>2491</th>\n",
729
+ " <th>2492</th>\n",
730
+ " <th>2493</th>\n",
731
+ " <th>2494</th>\n",
732
+ " <th>2495</th>\n",
733
+ " <th>2496</th>\n",
734
+ " <th>2497</th>\n",
735
+ " <th>2498</th>\n",
736
+ " <th>2499</th>\n",
737
+ " <th>class_labels</th>\n",
738
+ " </tr>\n",
739
+ " </thead>\n",
740
+ " <tbody>\n",
741
+ " <tr>\n",
742
+ " <th>0</th>\n",
743
+ " <td>143</td>\n",
744
+ " <td>149</td>\n",
745
+ " <td>160</td>\n",
746
+ " <td>169</td>\n",
747
+ " <td>167</td>\n",
748
+ " <td>167</td>\n",
749
+ " <td>145</td>\n",
750
+ " <td>144</td>\n",
751
+ " <td>144</td>\n",
752
+ " <td>159</td>\n",
753
+ " <td>...</td>\n",
754
+ " <td>174</td>\n",
755
+ " <td>168</td>\n",
756
+ " <td>149</td>\n",
757
+ " <td>134</td>\n",
758
+ " <td>128</td>\n",
759
+ " <td>137</td>\n",
760
+ " <td>137</td>\n",
761
+ " <td>131</td>\n",
762
+ " <td>127</td>\n",
763
+ " <td>daisy</td>\n",
764
+ " </tr>\n",
765
+ " <tr>\n",
766
+ " <th>1</th>\n",
767
+ " <td>224</td>\n",
768
+ " <td>222</td>\n",
769
+ " <td>216</td>\n",
770
+ " <td>232</td>\n",
771
+ " <td>228</td>\n",
772
+ " <td>75</td>\n",
773
+ " <td>85</td>\n",
774
+ " <td>80</td>\n",
775
+ " <td>182</td>\n",
776
+ " <td>185</td>\n",
777
+ " <td>...</td>\n",
778
+ " <td>116</td>\n",
779
+ " <td>107</td>\n",
780
+ " <td>110</td>\n",
781
+ " <td>108</td>\n",
782
+ " <td>156</td>\n",
783
+ " <td>169</td>\n",
784
+ " <td>141</td>\n",
785
+ " <td>125</td>\n",
786
+ " <td>172</td>\n",
787
+ " <td>daisy</td>\n",
788
+ " </tr>\n",
789
+ " <tr>\n",
790
+ " <th>2</th>\n",
791
+ " <td>108</td>\n",
792
+ " <td>81</td>\n",
793
+ " <td>97</td>\n",
794
+ " <td>84</td>\n",
795
+ " <td>102</td>\n",
796
+ " <td>120</td>\n",
797
+ " <td>108</td>\n",
798
+ " <td>106</td>\n",
799
+ " <td>140</td>\n",
800
+ " <td>128</td>\n",
801
+ " <td>...</td>\n",
802
+ " <td>44</td>\n",
803
+ " <td>27</td>\n",
804
+ " <td>26</td>\n",
805
+ " <td>26</td>\n",
806
+ " <td>27</td>\n",
807
+ " <td>27</td>\n",
808
+ " <td>31</td>\n",
809
+ " <td>36</td>\n",
810
+ " <td>40</td>\n",
811
+ " <td>daisy</td>\n",
812
+ " </tr>\n",
813
+ " <tr>\n",
814
+ " <th>3</th>\n",
815
+ " <td>26</td>\n",
816
+ " <td>25</td>\n",
817
+ " <td>26</td>\n",
818
+ " <td>29</td>\n",
819
+ " <td>32</td>\n",
820
+ " <td>35</td>\n",
821
+ " <td>37</td>\n",
822
+ " <td>38</td>\n",
823
+ " <td>38</td>\n",
824
+ " <td>40</td>\n",
825
+ " <td>...</td>\n",
826
+ " <td>16</td>\n",
827
+ " <td>15</td>\n",
828
+ " <td>16</td>\n",
829
+ " <td>21</td>\n",
830
+ " <td>18</td>\n",
831
+ " <td>24</td>\n",
832
+ " <td>16</td>\n",
833
+ " <td>20</td>\n",
834
+ " <td>23</td>\n",
835
+ " <td>daisy</td>\n",
836
+ " </tr>\n",
837
+ " <tr>\n",
838
+ " <th>4</th>\n",
839
+ " <td>20</td>\n",
840
+ " <td>21</td>\n",
841
+ " <td>36</td>\n",
842
+ " <td>45</td>\n",
843
+ " <td>46</td>\n",
844
+ " <td>45</td>\n",
845
+ " <td>40</td>\n",
846
+ " <td>42</td>\n",
847
+ " <td>37</td>\n",
848
+ " <td>56</td>\n",
849
+ " <td>...</td>\n",
850
+ " <td>42</td>\n",
851
+ " <td>48</td>\n",
852
+ " <td>42</td>\n",
853
+ " <td>26</td>\n",
854
+ " <td>25</td>\n",
855
+ " <td>31</td>\n",
856
+ " <td>39</td>\n",
857
+ " <td>27</td>\n",
858
+ " <td>35</td>\n",
859
+ " <td>daisy</td>\n",
860
+ " </tr>\n",
861
+ " <tr>\n",
862
+ " <th>...</th>\n",
863
+ " <td>...</td>\n",
864
+ " <td>...</td>\n",
865
+ " <td>...</td>\n",
866
+ " <td>...</td>\n",
867
+ " <td>...</td>\n",
868
+ " <td>...</td>\n",
869
+ " <td>...</td>\n",
870
+ " <td>...</td>\n",
871
+ " <td>...</td>\n",
872
+ " <td>...</td>\n",
873
+ " <td>...</td>\n",
874
+ " <td>...</td>\n",
875
+ " <td>...</td>\n",
876
+ " <td>...</td>\n",
877
+ " <td>...</td>\n",
878
+ " <td>...</td>\n",
879
+ " <td>...</td>\n",
880
+ " <td>...</td>\n",
881
+ " <td>...</td>\n",
882
+ " <td>...</td>\n",
883
+ " <td>...</td>\n",
884
+ " </tr>\n",
885
+ " <tr>\n",
886
+ " <th>3665</th>\n",
887
+ " <td>212</td>\n",
888
+ " <td>189</td>\n",
889
+ " <td>186</td>\n",
890
+ " <td>212</td>\n",
891
+ " <td>47</td>\n",
892
+ " <td>82</td>\n",
893
+ " <td>116</td>\n",
894
+ " <td>131</td>\n",
895
+ " <td>82</td>\n",
896
+ " <td>79</td>\n",
897
+ " <td>...</td>\n",
898
+ " <td>103</td>\n",
899
+ " <td>114</td>\n",
900
+ " <td>40</td>\n",
901
+ " <td>7</td>\n",
902
+ " <td>30</td>\n",
903
+ " <td>30</td>\n",
904
+ " <td>86</td>\n",
905
+ " <td>194</td>\n",
906
+ " <td>215</td>\n",
907
+ " <td>tulips</td>\n",
908
+ " </tr>\n",
909
+ " <tr>\n",
910
+ " <th>3666</th>\n",
911
+ " <td>135</td>\n",
912
+ " <td>126</td>\n",
913
+ " <td>129</td>\n",
914
+ " <td>131</td>\n",
915
+ " <td>119</td>\n",
916
+ " <td>141</td>\n",
917
+ " <td>135</td>\n",
918
+ " <td>128</td>\n",
919
+ " <td>132</td>\n",
920
+ " <td>136</td>\n",
921
+ " <td>...</td>\n",
922
+ " <td>53</td>\n",
923
+ " <td>60</td>\n",
924
+ " <td>58</td>\n",
925
+ " <td>54</td>\n",
926
+ " <td>41</td>\n",
927
+ " <td>48</td>\n",
928
+ " <td>84</td>\n",
929
+ " <td>132</td>\n",
930
+ " <td>120</td>\n",
931
+ " <td>tulips</td>\n",
932
+ " </tr>\n",
933
+ " <tr>\n",
934
+ " <th>3667</th>\n",
935
+ " <td>88</td>\n",
936
+ " <td>72</td>\n",
937
+ " <td>78</td>\n",
938
+ " <td>97</td>\n",
939
+ " <td>57</td>\n",
940
+ " <td>77</td>\n",
941
+ " <td>91</td>\n",
942
+ " <td>79</td>\n",
943
+ " <td>46</td>\n",
944
+ " <td>77</td>\n",
945
+ " <td>...</td>\n",
946
+ " <td>71</td>\n",
947
+ " <td>81</td>\n",
948
+ " <td>89</td>\n",
949
+ " <td>91</td>\n",
950
+ " <td>91</td>\n",
951
+ " <td>87</td>\n",
952
+ " <td>103</td>\n",
953
+ " <td>80</td>\n",
954
+ " <td>80</td>\n",
955
+ " <td>tulips</td>\n",
956
+ " </tr>\n",
957
+ " <tr>\n",
958
+ " <th>3668</th>\n",
959
+ " <td>157</td>\n",
960
+ " <td>189</td>\n",
961
+ " <td>169</td>\n",
962
+ " <td>132</td>\n",
963
+ " <td>174</td>\n",
964
+ " <td>162</td>\n",
965
+ " <td>185</td>\n",
966
+ " <td>174</td>\n",
967
+ " <td>122</td>\n",
968
+ " <td>160</td>\n",
969
+ " <td>...</td>\n",
970
+ " <td>152</td>\n",
971
+ " <td>193</td>\n",
972
+ " <td>74</td>\n",
973
+ " <td>23</td>\n",
974
+ " <td>18</td>\n",
975
+ " <td>8</td>\n",
976
+ " <td>12</td>\n",
977
+ " <td>19</td>\n",
978
+ " <td>45</td>\n",
979
+ " <td>tulips</td>\n",
980
+ " </tr>\n",
981
+ " <tr>\n",
982
+ " <th>3669</th>\n",
983
+ " <td>49</td>\n",
984
+ " <td>62</td>\n",
985
+ " <td>118</td>\n",
986
+ " <td>122</td>\n",
987
+ " <td>75</td>\n",
988
+ " <td>164</td>\n",
989
+ " <td>127</td>\n",
990
+ " <td>98</td>\n",
991
+ " <td>74</td>\n",
992
+ " <td>78</td>\n",
993
+ " <td>...</td>\n",
994
+ " <td>146</td>\n",
995
+ " <td>80</td>\n",
996
+ " <td>45</td>\n",
997
+ " <td>63</td>\n",
998
+ " <td>47</td>\n",
999
+ " <td>91</td>\n",
1000
+ " <td>56</td>\n",
1001
+ " <td>76</td>\n",
1002
+ " <td>57</td>\n",
1003
+ " <td>tulips</td>\n",
1004
+ " </tr>\n",
1005
+ " </tbody>\n",
1006
+ "</table>\n",
1007
+ "<p>3670 rows × 2501 columns</p>\n",
1008
+ "</div>"
1009
+ ],
1010
+ "text/plain": [
1011
+ " 0 1 2 3 4 5 6 7 8 9 ... 2491 2492 2493 \\\n",
1012
+ "0 143 149 160 169 167 167 145 144 144 159 ... 174 168 149 \n",
1013
+ "1 224 222 216 232 228 75 85 80 182 185 ... 116 107 110 \n",
1014
+ "2 108 81 97 84 102 120 108 106 140 128 ... 44 27 26 \n",
1015
+ "3 26 25 26 29 32 35 37 38 38 40 ... 16 15 16 \n",
1016
+ "4 20 21 36 45 46 45 40 42 37 56 ... 42 48 42 \n",
1017
+ "... ... ... ... ... ... ... ... ... ... ... ... ... ... ... \n",
1018
+ "3665 212 189 186 212 47 82 116 131 82 79 ... 103 114 40 \n",
1019
+ "3666 135 126 129 131 119 141 135 128 132 136 ... 53 60 58 \n",
1020
+ "3667 88 72 78 97 57 77 91 79 46 77 ... 71 81 89 \n",
1021
+ "3668 157 189 169 132 174 162 185 174 122 160 ... 152 193 74 \n",
1022
+ "3669 49 62 118 122 75 164 127 98 74 78 ... 146 80 45 \n",
1023
+ "\n",
1024
+ " 2494 2495 2496 2497 2498 2499 class_labels \n",
1025
+ "0 134 128 137 137 131 127 daisy \n",
1026
+ "1 108 156 169 141 125 172 daisy \n",
1027
+ "2 26 27 27 31 36 40 daisy \n",
1028
+ "3 21 18 24 16 20 23 daisy \n",
1029
+ "4 26 25 31 39 27 35 daisy \n",
1030
+ "... ... ... ... ... ... ... ... \n",
1031
+ "3665 7 30 30 86 194 215 tulips \n",
1032
+ "3666 54 41 48 84 132 120 tulips \n",
1033
+ "3667 91 91 87 103 80 80 tulips \n",
1034
+ "3668 23 18 8 12 19 45 tulips \n",
1035
+ "3669 63 47 91 56 76 57 tulips \n",
1036
+ "\n",
1037
+ "[3670 rows x 2501 columns]"
1038
+ ]
1039
+ },
1040
+ "execution_count": 49,
1041
+ "metadata": {},
1042
+ "output_type": "execute_result"
1043
+ }
1044
+ ],
1045
+ "source": [
1046
+ "final_data # Display the entire DataFrame to examine its structure and data."
1047
+ ]
1048
+ },
1049
+ {
1050
+ "cell_type": "code",
1051
+ "execution_count": 50,
1052
+ "id": "4bd4960b-0677-40bd-8256-73ed2fb70114",
1053
+ "metadata": {},
1054
+ "outputs": [
1055
+ {
1056
+ "name": "stdout",
1057
+ "output_type": "stream",
1058
+ "text": [
1059
+ "<class 'pandas.core.frame.DataFrame'>\n",
1060
+ "RangeIndex: 3670 entries, 0 to 3669\n",
1061
+ "Columns: 2501 entries, 0 to class_labels\n",
1062
+ "dtypes: object(1), uint8(2500)\n",
1063
+ "memory usage: 8.8+ MB\n"
1064
+ ]
1065
+ }
1066
+ ],
1067
+ "source": [
1068
+ "final_data.info() # Display detailed information about the DataFrame, including column types and memory usage."
1069
+ ]
1070
+ },
1071
+ {
1072
+ "cell_type": "code",
1073
+ "execution_count": null,
1074
+ "id": "b95f3573-f73a-468e-b12c-a605c93c6ded",
1075
+ "metadata": {},
1076
+ "outputs": [],
1077
+ "source": []
1078
+ },
1079
+ {
1080
+ "cell_type": "code",
1081
+ "execution_count": null,
1082
+ "id": "bab6163f-9907-4cce-9e21-c37eabb6b5a0",
1083
+ "metadata": {},
1084
+ "outputs": [],
1085
+ "source": []
1086
+ }
1087
+ ],
1088
+ "metadata": {
1089
+ "kernelspec": {
1090
+ "display_name": "Python 3 (ipykernel)",
1091
+ "language": "python",
1092
+ "name": "python3"
1093
+ },
1094
+ "language_info": {
1095
+ "codemirror_mode": {
1096
+ "name": "ipython",
1097
+ "version": 3
1098
+ },
1099
+ "file_extension": ".py",
1100
+ "mimetype": "text/x-python",
1101
+ "name": "python",
1102
+ "nbconvert_exporter": "python",
1103
+ "pygments_lexer": "ipython3",
1104
+ "version": "3.11.7"
1105
+ }
1106
+ },
1107
+ "nbformat": 4,
1108
+ "nbformat_minor": 5
1109
+ }
image_show(b,g,r)_in_window.ipynb ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 5,
6
+ "id": "2a48ed33-0649-440a-a672-366eccecc595",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "import cv2\n",
11
+ "import numpy as np"
12
+ ]
13
+ },
14
+ {
15
+ "cell_type": "code",
16
+ "execution_count": 9,
17
+ "id": "79e94481-02c5-41df-b243-b5ab9d6215cf",
18
+ "metadata": {},
19
+ "outputs": [],
20
+ "source": [
21
+ "white_img=np.full((400,500),255,dtype=np.uint8) # Create a white image (400x500 pixels) with all values set to 255."
22
+ ]
23
+ },
24
+ {
25
+ "cell_type": "code",
26
+ "execution_count": 10,
27
+ "id": "dafbe73b-1c9a-4ecd-a97b-273066fa722b",
28
+ "metadata": {},
29
+ "outputs": [
30
+ {
31
+ "data": {
32
+ "text/plain": [
33
+ "True"
34
+ ]
35
+ },
36
+ "execution_count": 10,
37
+ "metadata": {},
38
+ "output_type": "execute_result"
39
+ }
40
+ ],
41
+ "source": [
42
+ "cv2.imwrite(r\"C:\\Users\\Singh\\Downloads\\flower_photos\\white.jpg\",white_img) # Save the white image as \"white.jpg\" in the specified directory."
43
+ ]
44
+ },
45
+ {
46
+ "cell_type": "code",
47
+ "execution_count": 13,
48
+ "id": "84e50e23-dcac-4d6a-b1b9-a3cf10d4e4f0",
49
+ "metadata": {},
50
+ "outputs": [],
51
+ "source": [
52
+ "img=cv2.imread(r\"C:\\Users\\Singh\\Downloads\\flower_photos\\tulips\\54895006_55b49052dc.jpg\") # Load the image \"tulips\" from the specified directory."
53
+ ]
54
+ },
55
+ {
56
+ "cell_type": "code",
57
+ "execution_count": 14,
58
+ "id": "2f465e89-1151-4e14-ad1d-14208ee8ba43",
59
+ "metadata": {},
60
+ "outputs": [
61
+ {
62
+ "data": {
63
+ "text/plain": [
64
+ "(333, 500, 3)"
65
+ ]
66
+ },
67
+ "execution_count": 14,
68
+ "metadata": {},
69
+ "output_type": "execute_result"
70
+ }
71
+ ],
72
+ "source": [
73
+ "img.shape # Get the shape of the image (height, width, and color channels)."
74
+ ]
75
+ },
76
+ {
77
+ "cell_type": "code",
78
+ "execution_count": 17,
79
+ "id": "0b34448d-47eb-45be-8595-b08f1a17716d",
80
+ "metadata": {},
81
+ "outputs": [
82
+ {
83
+ "data": {
84
+ "text/plain": [
85
+ "(333, 500)"
86
+ ]
87
+ },
88
+ "execution_count": 17,
89
+ "metadata": {},
90
+ "output_type": "execute_result"
91
+ }
92
+ ],
93
+ "source": [
94
+ "img.shape[:-1] # Get only the height and width of the image by excluding the color channels."
95
+ ]
96
+ },
97
+ {
98
+ "cell_type": "code",
99
+ "execution_count": 16,
100
+ "id": "39a4831e-4415-4699-a0ae-24222370e0c3",
101
+ "metadata": {},
102
+ "outputs": [],
103
+ "source": [
104
+ "b,g,r=cv2.split(img) # Split the image into its blue (b), green (g), and red (r) channels."
105
+ ]
106
+ },
107
+ {
108
+ "cell_type": "code",
109
+ "execution_count": 19,
110
+ "id": "d56c4865-f80f-4cd7-af69-1b3437cb8315",
111
+ "metadata": {},
112
+ "outputs": [],
113
+ "source": [
114
+ "zeros=np.zeros(img.shape[:-1],dtype=np.uint8) # Create a zero matrix with the same height and width as the image for masking."
115
+ ]
116
+ },
117
+ {
118
+ "cell_type": "code",
119
+ "execution_count": 20,
120
+ "id": "cd625553-7992-4706-aae7-4bbaaf9daee6",
121
+ "metadata": {},
122
+ "outputs": [],
123
+ "source": [
124
+ "blue_channel=cv2.merge([b,zeros,zeros]) # Create the blue channel by combining the blue channel and zero matrices for other channels.\n",
125
+ "green_channel=cv2.merge([zeros,b,zeros]) # Create the green channel by combining the green channel and zero matrices for other channels.\n",
126
+ "red_channel=cv2.merge([zeros,zeros,r]) # Create the red channel by combining the red channel and zero matrices for other channels."
127
+ ]
128
+ },
129
+ {
130
+ "cell_type": "code",
131
+ "execution_count": null,
132
+ "id": "3c896f79-ec7d-4bcf-8db6-2e09d1551b6b",
133
+ "metadata": {},
134
+ "outputs": [],
135
+ "source": [
136
+ "cv2.imshow(\"blue_channel\",blue_channel) # Display the blue channel image in a window.\n",
137
+ "cv2.imshow(\"green_channel\",green_channel) # Display the green channel image in a window.\n",
138
+ "cv2.imshow(\"red_channel\",red_channel) # Display the red channel image in a window.\n",
139
+ "cv2.imshow(\"original_channel\",cv2.merge([b,g,r])) # Display the original image by merging the blue, green, and red channels back together.\n",
140
+ "\n",
141
+ "cv2.waitKey() # Wait indefinitely until a key is pressed.\n",
142
+ "cv2.destroyAllWindows() # Close all OpenCV windows."
143
+ ]
144
+ },
145
+ {
146
+ "cell_type": "code",
147
+ "execution_count": null,
148
+ "id": "12381df8-94f1-4523-bbd3-d6d26052c5da",
149
+ "metadata": {},
150
+ "outputs": [],
151
+ "source": []
152
+ }
153
+ ],
154
+ "metadata": {
155
+ "kernelspec": {
156
+ "display_name": "Python 3 (ipykernel)",
157
+ "language": "python",
158
+ "name": "python3"
159
+ },
160
+ "language_info": {
161
+ "codemirror_mode": {
162
+ "name": "ipython",
163
+ "version": 3
164
+ },
165
+ "file_extension": ".py",
166
+ "mimetype": "text/x-python",
167
+ "name": "python",
168
+ "nbconvert_exporter": "python",
169
+ "pygments_lexer": "ipython3",
170
+ "version": "3.11.7"
171
+ }
172
+ },
173
+ "nbformat": 4,
174
+ "nbformat_minor": 5
175
+ }