diff --git a/image_as_3d_array.ipynb b/image_as_3d_array.ipynb index a061ac0..407067d 100644 --- a/image_as_3d_array.ipynb +++ b/image_as_3d_array.ipynb @@ -49,13 +49,13 @@ "# loading image\n", "img = mpimg.imread('i/super_mario_head.png')\n", "# creates sub plots of 15x15\n", - "f, (plt1, plt2, plt3, plt4) = plt.subplots(1, 4,figsize=(15,15))\n", + "f, (plt1, plt2, plt3, plt4) = plt.subplots(1, 4, figsize=(15, 15))\n", "\n", - "plt1.set_title('Original');plt1.imshow(img);\n", + "plt1.set_title('Original'); plt1.imshow(img);\n", "# showing each channel img[x,y,color_plane] \n", - "plt2.axis('off');plt2.set_title('Red');plt2.imshow(img[:,:,0],cmap='gray');\n", - "plt3.axis('off');plt3.set_title('Luigi');plt3.imshow(img[:,:,1],cmap='gray');\n", - "plt4.axis('off');plt4.set_title('Blue');plt4.imshow(img[:,:,2],cmap='gray');" + "plt2.axis('off'); plt2.set_title('Red'); plt2.imshow(img[:,:,0], cmap='gray');\n", + "plt3.axis('off'); plt3.set_title('Luigi'); plt3.imshow(img[:,:,1], cmap='gray');\n", + "plt4.axis('off'); plt4.set_title('Blue'); plt4.imshow(img[:,:,2], cmap='gray');" ] }, { @@ -78,17 +78,17 @@ ], "source": [ "# creates sub plots of 15x15\n", - "f, (plt1, plt2, plt3, plt4) = plt.subplots(1, 4,figsize=(15,15))\n", + "f, (plt1, plt2, plt3, plt4) = plt.subplots(1, 4, figsize=(15, 15))\n", "\n", "# cutting the image\n", - "eye_brow = img[100:150,150:200,]\n", - "eye_split = eye_brow[40:50,20:30]\n", - "zoomed_eye_split = eye_split[4:8,0:4]\n", + "eye_brow = img[100:150, 150:200,]\n", + "eye_split = eye_brow[40:50, 20:30]\n", + "zoomed_eye_split = eye_split[4:8, 0:4]\n", "\n", - "plt1.axis('off');plt1.imshow(img,interpolation='nearest');\n", - "plt2.axis('off');plt2.imshow(eye_brow,interpolation='nearest');\n", - "plt3.axis('off');plt3.imshow(eye_split,interpolation='nearest');\n", - "plt4.axis('off');plt4.imshow(zoomed_eye_split,interpolation='nearest');" + "plt1.axis('off'); plt1.imshow(img, interpolation='nearest');\n", + "plt2.axis('off'); plt2.imshow(eye_brow, interpolation='nearest');\n", + "plt3.axis('off'); plt3.imshow(eye_split, interpolation='nearest');\n", + "plt4.axis('off'); plt4.imshow(zoomed_eye_split, interpolation='nearest');" ] }, { @@ -109,17 +109,17 @@ "name": "stdout", "output_type": "stream", "text": [ - "R intensity at x=3, y=3 is 0.0\n", - "G intensity at x=3, y=3 is 0.0\n", - "B intensity at x=3, y=3 is 1.0\n" + "R intensity at x=3, y=3 is 0\n", + "G intensity at x=3, y=3 is 59\n", + "B intensity at x=3, y=3 is 120\n" ] } ], "source": [ - "latest_pixel = zoomed_eye_split[3,3]\n", - "print(\"R intensity at x=3, y=3 is\",round(latest_pixel[0]))\n", - "print(\"G intensity at x=3, y=3 is\",round(latest_pixel[1]))\n", - "print(\"B intensity at x=3, y=3 is\",round(latest_pixel[2]))" + "latest_pixel = zoomed_eye_split[3, 3]\n", + "print(\"R intensity at x=3, y=3 is\",round(256 * latest_pixel[0]))\n", + "print(\"G intensity at x=3, y=3 is\",round(256 * latest_pixel[1]))\n", + "print(\"B intensity at x=3, y=3 is\",round(256 * latest_pixel[2]))" ] } ],