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

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.

主站蜘蛛池模板: 米泉市| 改则县| 鄂温| 昭苏县| 武汉市| 南华县| 玉门市| 专栏| 叶城县| 富宁县| 秦安县| 瓮安县| 化德县| 白山市| 调兵山市| 临猗县| 宝山区| 白沙| 柞水县| 灵山县| 通州市| 连南| 吴川市| 新巴尔虎右旗| 濮阳市| 安平县| 浪卡子县| 康保县| 尤溪县| 乌鲁木齐县| 昭通市| 宽甸| 永吉县| 竹溪县| 宜君县| 交城县| 罗源县| 汕尾市| 桃园县| 朔州市| 东宁县|