Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 165 - 2615_KEC
P. 165

    DIFFERENT WAYS TO PROCESS AN IMAGE

                     When a computer looks at an image, it does not see flowers, faces or objects. It sees numbers
                     arranged in rows and columns. OpenCV helps us work with these numbers so that we can change,
                     analyse and improve images in many useful ways.

                     In OpenCV, an image can be processed in different ways such as changing its colour format,
                     resizing it, cropping a part of it, adjusting brightness, detecting edges, blurring noise, or identifying
                     shapes and objects. Each operation changes the pixel values in a controlled manner to achieve a
                     specific result.

                     By  learning different image  processing  techniques  in OpenCV, students  can understand  how
                     computers edit photos, recognise faces, detect motion, and even power smart applications like
                     self-driving cars and security systems.

                     THE IMREAD() FUNCTION IN OPENCV

                     The imread() function in OpenCV is used to load an image from a file into a program. It reads
                     the image from a specified path and stores it in a format that OpenCV can process.
                     When an image is read using imread(), it is converted into a matrix of pixel values. Each pixel
                     contains information about colour or brightness, depending on the type of image.

                     By default, imread() loads an image in colour mode. However, it can also load an image in
                     grayscale or unchanged mode if specified. Grayscale images contain only intensity values, while
                     colour images contain three channels representing Blue, Green and Red.

                     If the file path is incorrect or the image cannot be found, the function returns an empty result.
                     Therefore, it is important to ensure that the correct file location is provided.

                     In simple terms, imread() is the first step in image processing with OpenCV, as it allows the
                     program to access and analyse the image data.

                     Syntax:
                     imread() function is: cv2.imread(path, flag)

                     Where,

                     path is the path of the image to be read. If the file is in the working directory, then write only the
                     name and the extension of the image otherwise it is a must to specify the complete path.
                     flag is the way how our image should be read.

                     READING AND DISPLAYING AN IMAGE
                     Reading an image means loading it from a file into a program so that it can be processed. In
                     OpenCV, this is done using the imread() function. When the image is read, it is converted into
                     a matrix of pixel values. If the file path is correct, the image data is stored in memory. If the path

                     is incorrect, the image will not load properly.

                                                                                                            OpenCV    163

| 160 161 162 163 164 165 166 167 168 169 170 |