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

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.

主站蜘蛛池模板: 玉环县| 阳朔县| 凉城县| 马关县| 茌平县| 鸡泽县| 深水埗区| 阳东县| 嘉义县| 临海市| 布拖县| 江山市| 墨脱县| 措美县| 镇雄县| 河东区| 凌海市| 固始县| 新昌县| 黑水县| 丹东市| 中宁县| 隆化县| 枝江市| 淳化县| 华坪县| 来安县| 双柏县| 常山县| 洛川县| 临朐县| 原平市| 江川县| 仁怀市| 富阳市| 蒙山县| 南投县| 樟树市| 河东区| 缙云县| 永兴县|