Day-3: Image Processing and ML
Image Processing
* Computer Vision of Picture is done by Image processing.
Image processing Involves Creating a photo, Cropping a Photo, Opening a Photo.
Image processing is done by Array(Numpy Array)
* Let's Play with Numpy with some useful examples
Example(1).
(1.1) List of 1, 2, 3, 4
(1.2) Names Vimal, Pop, Krish
- Shape command is used to know the type of DIMENSION in Image processing.
- The above result of shape is 1D, also Called VECTOR
(1.3) Lets do example in 2D array,
In this, we use Matrix i/p and o/p is shown.
The SHAPE here is " 2D Array ".
* In Data Science, we use Multi-Dimensional Array.
(1.4) Lets do example in converting 1D to 2D array,
Reshape command is used to convert 1D to 3D array as shown above
This way of reshaping is also used in Image Processing.
- 1D array is called Vector
- 2D or more than 2D is called Metrix or Multi-Dimensional Array
(1.5) Lets do example in creating array of Zero's using command line.
(1.6) Lets do example in creating Algebraic expressions.
From all these above examples, we use these Array concepts in Image Processing.
* Let's work on
Image Processing
by discussing Image Viewing, Creating Imaging and Cropping Image.
Image Viewing:
- Double clicking will Open an image, its program written by someone.
- We here, use Python programming in Viewing, Cropping and creating a Photo.
* Practice and result is shown below,
* Should Import cv2 module, " import cv2 "
Check cv module in panda list, if not there in list. Install it by running
" pin install opencv-python "
* Run " x = cv2.imread('1.jpg') "
the jpg should be in same working directory of python code file
this Command will read the jpg from directory.
* Run
Hi is name in braces which is choosy.
In waitkey(), braces should be time in (millisec).
The Destroy command, will autoclose the pic after the time mentioned in waitkey command.
Color to Gray Conversion:
Creating Photo:
* Create a Table and make into Rows * Columns.
Fill the boxes with some color as above, leaving some boxes in white. We can observe it as Numeric '1' from distance.
Any Image is exactly same as table with rows and columns.
* In a box, it will have data. this data in Picture is called " Pixel ".
this pixel will have color.
* According to RAM(loading)/CPU(Process)/H.D(Store), they never understand the color . They understand the Number only.
- Any color in box is stored as a Number in H.D as a " R B G ", this is shown by RAM through CPU.
- In Numpy Array, the pixel data will be in " B G R " form.
* In Every box, we have multiple data it is called 3D array or Multi-Dimensional Array.
- All colorful images are 3D array.
- Range of R/B/G: 0-255
- Image == Numpy Array
- Black & White is 2D Array
- Gray image is 2D Array.
Cropping a Photo:
Lets do a basic example, before going to cropping discussion.
the same procedure is done in Cropping a Picture.
Lets jump on cropping pic, as below
Use cases
(1) Specifying a Green Dot in pic:
(2) Drawing a Green line on pic:
(3). Main Agenda of cropping a pic:
Day-3 & Day-4 ML concepts are repeated and little advanced on Day-4. So, will update it in 9th(Day-4) Article.
Absolute Summary !