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

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.

主站蜘蛛池模板: 永昌县| 宁德市| 星子县| 长乐市| 旬邑县| 都昌县| 泸定县| 九江县| 错那县| 仙居县| 五原县| 界首市| 察雅县| 固始县| 崇明县| 万盛区| 安龙县| 上饶市| 徐闻县| 买车| 苍山县| 虹口区| 灯塔市| 蓬安县| 威宁| 西乌珠穆沁旗| 光泽县| 洞头县| 固安县| 昭苏县| 巴塘县| 同仁县| 石棉县| 章丘市| 彩票| 永善县| 潜江市| 贵溪市| 班玛县| 林州市| 额济纳旗|