官术网_书友最值得收藏!

Reading an image 

An image, stored in digital format, consists of grid structure with each cell containing a value to represent image. In further sections, we will see different formats for images. For each format, the values represented in the grid cells will have different range of values. 

To manipulate an image or use it for further processing, we need to load the image and use it as grid like structure. This is referred to as image input-output operations and we can use OpenCV library to read an image, as follows. Here, change the path to the image file according to use:

import cv2 

# loads and read an image from path to file
img = cv2.imread('../figures/flower.png')

# displays previous image
cv2.imshow("Image",img)

# keeps the window open until a key is pressed
cv2.waitKey(0)

# clears all window buffers
cv2.destroyAllWindows()

The resulting image is shown in the following screenshot:

Here, we read the image in BGR color format where B is blue, G is green, and R is red. Each pixel in the output is collectively represented using the values of each of the colors. An example of the pixel location and its color values is shown in the previous figure bottom.

主站蜘蛛池模板: 高青县| 宝兴县| 多伦县| 蒙山县| 察隅县| 巩留县| 锡林郭勒盟| 长沙市| 尤溪县| 临颍县| 板桥市| 凌海市| 玉环县| 延寿县| 石河子市| 乌审旗| 达孜县| 新昌县| 威远县| 大理市| 于都县| 桑日县| 尤溪县| 务川| 洛扎县| 封开县| 图们市| 松江区| 广州市| 蒙城县| 马山县| 西林县| 安岳县| 延吉市| 定兴县| 香格里拉县| 玛曲县| 平顺县| 潮安县| 宁波市| 遵化市|