mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
Merge pull request #23108 from crackwitz:issue-23107
Usage of imread(): magic number 0, unchecked result * docs: rewrite 0/1 to IMREAD_GRAYSCALE/IMREAD_COLOR in imread() * samples, apps: rewrite 0/1 to IMREAD_GRAYSCALE/IMREAD_COLOR in imread() * tests: rewrite 0/1 to IMREAD_GRAYSCALE/IMREAD_COLOR in imread() * doc/py_tutorials: check imread() result
This commit is contained in:
committed by
GitHub
parent
7b7774476e
commit
a64b51dd94
@@ -25,6 +25,7 @@ Let's load a color image first:
|
||||
>>> import cv2 as cv
|
||||
|
||||
>>> img = cv.imread('messi5.jpg')
|
||||
>>> assert img is not None, "file could not be read, check with os.path.exists()"
|
||||
@endcode
|
||||
You can access a pixel value by its row and column coordinates. For BGR image, it returns an array
|
||||
of Blue, Green, Red values. For grayscale image, just corresponding intensity is returned.
|
||||
@@ -173,6 +174,7 @@ from matplotlib import pyplot as plt
|
||||
BLUE = [255,0,0]
|
||||
|
||||
img1 = cv.imread('opencv-logo.png')
|
||||
assert img1 is not None, "file could not be read, check with os.path.exists()"
|
||||
|
||||
replicate = cv.copyMakeBorder(img1,10,10,10,10,cv.BORDER_REPLICATE)
|
||||
reflect = cv.copyMakeBorder(img1,10,10,10,10,cv.BORDER_REFLECT)
|
||||
|
||||
@@ -50,6 +50,8 @@ Here \f$\gamma\f$ is taken as zero.
|
||||
@code{.py}
|
||||
img1 = cv.imread('ml.png')
|
||||
img2 = cv.imread('opencv-logo.png')
|
||||
assert img1 is not None, "file could not be read, check with os.path.exists()"
|
||||
assert img2 is not None, "file could not be read, check with os.path.exists()"
|
||||
|
||||
dst = cv.addWeighted(img1,0.7,img2,0.3,0)
|
||||
|
||||
@@ -76,6 +78,8 @@ bitwise operations as shown below:
|
||||
# Load two images
|
||||
img1 = cv.imread('messi5.jpg')
|
||||
img2 = cv.imread('opencv-logo-white.png')
|
||||
assert img1 is not None, "file could not be read, check with os.path.exists()"
|
||||
assert img2 is not None, "file could not be read, check with os.path.exists()"
|
||||
|
||||
# I want to put logo on top-left corner, So I create a ROI
|
||||
rows,cols,channels = img2.shape
|
||||
|
||||
@@ -37,6 +37,7 @@ of odd sizes ranging from 5 to 49. (Don't worry about what the result will look
|
||||
goal):
|
||||
@code{.py}
|
||||
img1 = cv.imread('messi5.jpg')
|
||||
assert img1 is not None, "file could not be read, check with os.path.exists()"
|
||||
|
||||
e1 = cv.getTickCount()
|
||||
for i in range(5,49,2):
|
||||
|
||||
Reference in New Issue
Block a user