├── Image_Processing.ipynb ├── Images ├── heic2007a.jpg ├── heic2007a_binary_1.png ├── heic2007a_blended.jpg ├── heic2007a_blue.jpg ├── heic2007a_contour_1.png ├── heic2007a_gray.jpg ├── heic2007a_green.jpg ├── heic2007a_red.jpg ├── heic2007a_resized.jpg └── img1.png └── README.md /Image_Processing.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Image Processing using Python" 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": 4, 13 | "metadata": {}, 14 | "outputs": [ 15 | { 16 | "name": "stdout", 17 | "output_type": "stream", 18 | "text": [ 19 | "original image dimensions:\n", 20 | "1024 1280 3\n", 21 | "gray image dimensions:\n", 22 | "1024 1280\n", 23 | "To merge image dimensions:\n", 24 | "1024 1280 3\n", 25 | "Resized image dimensions:\n", 26 | "256 256\n", 27 | "\n", 28 | "The gray image is successfully saved.\n", 29 | "The resized image is successfully saved.\n", 30 | "The red image is successfully saved.\n", 31 | "The blue image is successfully saved.\n", 32 | "The green image is successfully saved.\n", 33 | "The blended image is successfully saved.\n" 34 | ] 35 | } 36 | ], 37 | "source": [ 38 | "import cv2\n", 39 | "import numpy as np\n", 40 | "#import pandas as pd\n", 41 | "\n", 42 | "image = cv2.imread(r'C:/Users/Arvind/Desktop/Images/heic2007a.jpg')\n", 43 | "row,col,plane = image.shape\n", 44 | "print('original image dimensions:')\n", 45 | "print(row,col,plane)\n", 46 | "\n", 47 | "gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)\n", 48 | "row1,col1 = gray.shape\n", 49 | "print('gray image dimensions:')\n", 50 | "print(row1,col1)\n", 51 | "\n", 52 | "image2 = cv2.imread(r'C:/Users/Arvind/Desktop/Images/img1.png')\n", 53 | "row2,col2,plane2 = image2.shape\n", 54 | "print('To merge image dimensions:')\n", 55 | "print(row,col,plane)\n", 56 | "\n", 57 | "dsize = (256,256)\n", 58 | "\n", 59 | "# resize image\n", 60 | "output = cv2.resize(image, dsize)\n", 61 | "output1 = cv2.resize(image2, dsize)\n", 62 | " \n", 63 | "# add or blend the images\n", 64 | "output_b = cv2.addWeighted(output, 1, output1, 1, 0.0)\n", 65 | "\n", 66 | "#gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)\n", 67 | "row1,col1,plane= output.shape\n", 68 | "print('Resized image dimensions:')\n", 69 | "print(row1,col1)\n", 70 | " \n", 71 | "cv2.imshow('Resized image', output)\n", 72 | "cv2.imshow('Original image',image)\n", 73 | "cv2.imshow('Gray image', gray)\n", 74 | "\n", 75 | "red_image = np.zeros((row,col,plane),np.uint8)\n", 76 | "\n", 77 | "red_image[:,:,2]=image[:,:,2]\n", 78 | "cv2.imshow('Red image', red_image)\n", 79 | "\n", 80 | "green_image = np.zeros((row,col,plane),np.uint8)\n", 81 | "\n", 82 | "green_image[:,:,1]=image[:,:,1]\n", 83 | "cv2.imshow('Green image', green_image)\n", 84 | "\n", 85 | "blue_image = np.zeros((row,col,plane),np.uint8)\n", 86 | "\n", 87 | "blue_image[:,:,0]=image[:,:,0]\n", 88 | "cv2.imshow('Blue image', blue_image)\n", 89 | "\n", 90 | "cv2.imshow('Title image', image2)\n", 91 | "\n", 92 | "cv2.imshow('Blended image', output_b)\n", 93 | "\n", 94 | "cv2.waitKey(0)\n", 95 | "\n", 96 | "print('')\n", 97 | "\n", 98 | "isWritten1 = cv2.imwrite(r'C:/Users/Arvind/Desktop/Images/heic2007a_gray.jpg', gray)\n", 99 | "if isWritten1:\n", 100 | " print('The gray image is successfully saved.')\n", 101 | " \n", 102 | "isWritten2 = cv2.imwrite(r'C:/Users/Arvind/Desktop/Images/heic2007a_resized.jpg', output)\n", 103 | "if isWritten2:\n", 104 | " print('The resized image is successfully saved.')\n", 105 | " \n", 106 | "isWritten3 = cv2.imwrite(r'C:/Users/Arvind/Desktop/Images/heic2007a_red.jpg', red_image)\n", 107 | "if isWritten3:\n", 108 | " print('The red image is successfully saved.')\n", 109 | " \n", 110 | "isWritten4 = cv2.imwrite(r'C:/Users/Arvind/Desktop/Images/heic2007a_blue.jpg', blue_image)\n", 111 | "if isWritten4:\n", 112 | " print('The blue image is successfully saved.')\n", 113 | " \n", 114 | "isWritten5 = cv2.imwrite(r'C:/Users/Arvind/Desktop/Images/heic2007a_green.jpg', green_image)\n", 115 | "if isWritten5:\n", 116 | " print('The green image is successfully saved.')\n", 117 | " \n", 118 | "isWritten6 = cv2.imwrite(r'C:/Users/Arvind/Desktop/Images/heic2007a_blended.jpg', output_b)\n", 119 | "if isWritten6:\n", 120 | " print('The blended image is successfully saved.')\n", 121 | " \n", 122 | "cv2.destroyAllWindows()" 123 | ] 124 | }, 125 | { 126 | "cell_type": "code", 127 | "execution_count": null, 128 | "metadata": {}, 129 | "outputs": [], 130 | "source": [] 131 | } 132 | ], 133 | "metadata": { 134 | "kernelspec": { 135 | "display_name": "Python 3", 136 | "language": "python", 137 | "name": "python3" 138 | }, 139 | "language_info": { 140 | "codemirror_mode": { 141 | "name": "ipython", 142 | "version": 3 143 | }, 144 | "file_extension": ".py", 145 | "mimetype": "text/x-python", 146 | "name": "python", 147 | "nbconvert_exporter": "python", 148 | "pygments_lexer": "ipython3", 149 | "version": "3.8.5" 150 | } 151 | }, 152 | "nbformat": 4, 153 | "nbformat_minor": 4 154 | } 155 | -------------------------------------------------------------------------------- /Images/heic2007a.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/naruhitokaide/Image-Processing-Python/d813ade692f58ef0bb75e56e8f1abcb7e6aabc08/Images/heic2007a.jpg -------------------------------------------------------------------------------- /Images/heic2007a_binary_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/naruhitokaide/Image-Processing-Python/d813ade692f58ef0bb75e56e8f1abcb7e6aabc08/Images/heic2007a_binary_1.png -------------------------------------------------------------------------------- /Images/heic2007a_blended.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/naruhitokaide/Image-Processing-Python/d813ade692f58ef0bb75e56e8f1abcb7e6aabc08/Images/heic2007a_blended.jpg -------------------------------------------------------------------------------- /Images/heic2007a_blue.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/naruhitokaide/Image-Processing-Python/d813ade692f58ef0bb75e56e8f1abcb7e6aabc08/Images/heic2007a_blue.jpg -------------------------------------------------------------------------------- /Images/heic2007a_contour_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/naruhitokaide/Image-Processing-Python/d813ade692f58ef0bb75e56e8f1abcb7e6aabc08/Images/heic2007a_contour_1.png -------------------------------------------------------------------------------- /Images/heic2007a_gray.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/naruhitokaide/Image-Processing-Python/d813ade692f58ef0bb75e56e8f1abcb7e6aabc08/Images/heic2007a_gray.jpg -------------------------------------------------------------------------------- /Images/heic2007a_green.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/naruhitokaide/Image-Processing-Python/d813ade692f58ef0bb75e56e8f1abcb7e6aabc08/Images/heic2007a_green.jpg -------------------------------------------------------------------------------- /Images/heic2007a_red.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/naruhitokaide/Image-Processing-Python/d813ade692f58ef0bb75e56e8f1abcb7e6aabc08/Images/heic2007a_red.jpg -------------------------------------------------------------------------------- /Images/heic2007a_resized.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/naruhitokaide/Image-Processing-Python/d813ade692f58ef0bb75e56e8f1abcb7e6aabc08/Images/heic2007a_resized.jpg -------------------------------------------------------------------------------- /Images/img1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/naruhitokaide/Image-Processing-Python/d813ade692f58ef0bb75e56e8f1abcb7e6aabc08/Images/img1.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Image-Processing-Python --------------------------------------------------------------------------------