Skip to content

Commit d12e761

Browse files
committed
Remove L6 answers
1 parent 311d003 commit d12e761

File tree

1 file changed

+9
-34
lines changed

1 file changed

+9
-34
lines changed

notebooks/lab-6/lab6-part1-numpy.ipynb

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@
227227
"source": [
228228
"\n",
229229
"def crop_img(img):\n",
230-
"\timg = img[250:800, 100:450, :]\n",
231-
"\treturn img\n",
230+
" # Implement your function here\n",
231+
" return img\n",
232232
"\n",
233233
"img = load_image(\"cs41img.png\").copy()\n",
234234
"save_image(crop_img(img), \"cs41img_cropped.png\")"
@@ -261,9 +261,7 @@
261261
"outputs": [],
262262
"source": [
263263
"def green_img(img):\n",
264-
"\timg = img[:, :, 1]\n",
265-
"\tzeros = np.zeros(img.shape)\n",
266-
"\timg = np.stack((zeros, img, zeros), axis=2)\n",
264+
" # Implement your function here\n",
267265
"\treturn img\n",
268266
"\n",
269267
"img = load_image(\"cs41img.png\").copy()\n",
@@ -296,15 +294,8 @@
296294
"source": [
297295
"\n",
298296
"def third_third_third(img):\n",
299-
"\tred = img[:int(img.shape[0]/3), :, 0]\n",
300-
"\tgreen = img[int(img.shape[0]/3):int(2*img.shape[0]/3), :, 1]\n",
301-
"\tblue = img[int(2*img.shape[0]/3):, :, 2]\n",
302-
"\n",
303-
"\tred = np.stack((red, np.zeros(red.shape), np.zeros(red.shape)), axis=2)\n",
304-
"\tgreen = np.stack((np.zeros(green.shape), np.zeros(green.shape), green), axis=2)\n",
305-
"\tblue = np.stack((np.zeros(blue.shape), blue, np.zeros(blue.shape)), axis=2)\n",
306-
"\n",
307-
"\treturn np.concatenate((red, green, blue), axis=0)\n",
297+
" # Implement your function here\n",
298+
" return img\n",
308299
"\n",
309300
"img = load_image(\"cs41img.png\").copy()\n",
310301
"save_image(third_third_third(img), \"cs41img_third.png\")"
@@ -338,10 +329,7 @@
338329
"source": [
339330
"\n",
340331
"def brightness(img, factor):\n",
341-
"\tfor row in range(img.shape[0]):\n",
342-
"\t\tfor col in range(img.shape[1]):\n",
343-
"\t\t\tfor color in range(img.shape[2]):\n",
344-
"\t\t\t\timg[row, col, color] = min(img[row, col, color]*factor, 255)\n",
332+
" # Implement your function here\n",
345333
"\treturn img\n",
346334
"\n",
347335
"img = load_image(\"cs41img.png\").copy()\n",
@@ -369,14 +357,7 @@
369357
"outputs": [],
370358
"source": [
371359
"def contrast(img, factor):\n",
372-
"\tfor row in range(img.shape[0]):\n",
373-
"\t\tfor col in range(img.shape[1]):\n",
374-
"\t\t\tfor color in range(img.shape[2]):\n",
375-
"\t\t\t\tif img[row, col, color] < 128:\n",
376-
"\t\t\t\t\timg[row, col, color] = img[row, col, color]/factor\n",
377-
"\t\t\t\telse:\n",
378-
"\t\t\t\t\timg[row, col, color] = min(img[row, col, color]*factor, 255)\n",
379-
"\n",
360+
" # Implement your function here\n",
380361
"\treturn img\n",
381362
"\n",
382363
"img = load_image(\"cs41img.png\").copy()\n",
@@ -418,13 +399,7 @@
418399
"outputs": [],
419400
"source": [
420401
"def reconstruct(img1, img2, img3):\n",
421-
" reconstructed_img = np.zeros(img1.shape)\n",
422-
" for row in range(img1.shape[0]):\n",
423-
" for col in range(img1.shape[1]):\n",
424-
" for color in range(img1.shape[2]):\n",
425-
" pixel_choices = np.asarray([img1[row, col, color], img2[row, col, color], img3[row, col, color]])\n",
426-
" reconstructed_img[row, col, color] = np.argmax(np.bincount(pixel_choices))\n",
427-
"\n",
402+
" # Implement your function here\n",
428403
" return reconstructed_img\n",
429404
"\n",
430405
"img1 = load_image(\"SOLcs41img_unicorn1.png\").copy()\n",
@@ -547,7 +522,7 @@
547522
"name": "python",
548523
"nbconvert_exporter": "python",
549524
"pygments_lexer": "ipython3",
550-
"version": "3.8.0"
525+
"version": "3.7.4"
551526
}
552527
},
553528
"nbformat": 4,

0 commit comments

Comments
 (0)