亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

Read an Image in OpenCV ( Python, C++ )

系統 1760 0
原文鏈接: https://www.learnopencv.com/read-an-image-in-opencv-python-cpp/

In OpenCV you can easily read in images with different file formats (JPG, PNG, TIFF etc.) using? imread . The basic usage is shown below

C++

?

Mat imread( const string& filename, int flags=IMREAD_COLOR )

Python

?

image = cv2.imread(filename, flags = cv2.IMREAD_COLOR)

The? flags ?option is used to control how the image is read. Let’s look at some common examples. In all the examples below, make sure you use the right namespace for C++ and import OpenCV for Python.
C++

?

using namespace cv;

Python

?

import cv2

Read as 8-bit / channel Color Image ( without Alpha Channel)

A vast majority of images are 8-bit per channel ( or 24-bit ) images. They can be read using default flags.

C++

?

Mat image = imread( "image.jpg" );

Python

?

image = cv2.imread( "image.jpg" )

Read as 8-bit Grayscale Image

C++

?

Mat image = imread( "image.jpg" , IMREAD_GRAYSCALE);

Python

?

image = cv2.imread( "image.jpg" , cv2.IMREAD_GRAYSCALE)

Read 16-bit / channel Color Image

Most digital SLR cameras are capable of recording images at a higher bit depth than 8-bits / channel. The raw images from these cameras can be converted to 16-bit / channel PNG or TIFF images. These 16-bit / channel images can be read using
C++

?

Mat image = imread( "image.png" , IMREAD_ANYCOLOR | IMREAD_ANYDEPTH);

Python

?

im = cv2.imread( "image.png" , cv2.IMREAD_ANYCOLOR | cv2.IMREAD_ANYDEPTH)

You may also use the flag IMREAD_UNCHANGED instead. See an example below.

Read a Transparent PNG or TIFF in OpenCV

A transparent image has four channels — 3 for color, and one for transparency. These images can be read in OpenCV using the IMREAD_UNCHANGED flag.
C++

?

Mat image = imread( "image.png" , IMREAD_UNCHANGED);

Python

?

im = cv2.imread( "image.png" , cv2.IMREAD_UNCHANGED)

NOTE :? CV_LOAD_IMAGE_COLOR, CV_LOAD_IMAGE_GRAYSCALE, CV_LOAD_IMAGE_ANYCOLOR, CV_LOAD_IMAGE_ANYDEPTH, and CV_LOAD_IMAGE_UNCHANGED will be removed in future versions of OpenCV.


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 日本不卡中文字幕一区二区 | 福利岛国深夜在线 | 亚洲精品久久婷婷爱久久婷婷 | www.色94色.com| 欧美日韩视频精品一区二区 | 天天噜夜夜操 | 青青免费视频视频在线 | 奇米在线影视 | 五月花精品视频在线观看 | 欧美日韩视频精品一区二区 | 香蕉视频网站 | 欧美一级毛片免费高清aa | 四虎欧美在线观看免费 | 亚洲精品亚洲人成在线 | 在线欧美69v免费观看视频 | 欧美韩国日本一区 | jizzjizz亚洲女人 | 亚洲在线观看 | 四虎影视永久在线精品免费播放 | 日本一区二区三区四区在线观看 | 国产亚洲一区二区三区在线观看 | 老师邪恶影院a啦啦啦影院 老师在办公室被躁到白浆 老湿机午夜影院 | 亚洲激情网址 | 亚洲国产一区视频 | 国产91小视频在线观看 | 日日草夜夜操 | 亚洲精品国产美女在线观看 | 99精品视频在线视频免费观看 | 久久久久九九精品影院 | 四虎国产精品免费久久影院 | 日本8888xxxx免费视频 | 亚洲欧美卡通成人制服动漫 | 深夜影院在线视频观看 | 在线观看视频亚洲 | 99热爱| 免费欧美一级片 | 久久综合九色综合91 | 欧美另类综合 | 亚洲天堂久久新 | 成人久久网站 | 国产激情视频在线 |