1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

py_tutorials: add print() braces for python3

This commit is contained in:
berak
2017-05-28 11:07:15 +02:00
parent 17b89b2a35
commit 0f51155e79
18 changed files with 41 additions and 41 deletions
@@ -30,18 +30,18 @@ You can access a pixel value by its row and column coordinates. For BGR image, i
of Blue, Green, Red values. For grayscale image, just corresponding intensity is returned.
@code{.py}
>>> px = img[100,100]
>>> print px
>>> print( px )
[157 166 200]
# accessing only blue pixel
>>> blue = img[100,100,0]
>>> print blue
>>> print( blue )
157
@endcode
You can modify the pixel values the same way.
@code{.py}
>>> img[100,100] = [255,255,255]
>>> print img[100,100]
>>> print( img[100,100] )
[255 255 255]
@endcode
@@ -76,7 +76,7 @@ etc.
Shape of image is accessed by img.shape. It returns a tuple of number of rows, columns and channels
(if image is color):
@code{.py}
>>> print img.shape
>>> print( img.shape )
(342, 548, 3)
@endcode
@@ -85,12 +85,12 @@ good method to check if loaded image is grayscale or color image.
Total number of pixels is accessed by `img.size`:
@code{.py}
>>> print img.size
>>> print( img.size )
562248
@endcode
Image datatype is obtained by \`img.dtype\`:
@code{.py}
>>> print img.dtype
>>> print( img.dtype )
uint8
@endcode
@@ -23,10 +23,10 @@ For example, consider below sample:
>>> x = np.uint8([250])
>>> y = np.uint8([10])
>>> print cv2.add(x,y) # 250+10 = 260 => 255
>>> print( cv2.add(x,y) ) # 250+10 = 260 => 255
[[255]]
>>> print x+y # 250+10 = 260 % 256 = 4
>>> print( x+y ) # 250+10 = 260 % 256 = 4
[4]
@endcode
It will be more visible when you add two images. OpenCV function will provide a better result. So
@@ -44,7 +44,7 @@ for i in xrange(5,49,2):
img1 = cv2.medianBlur(img1,i)
e2 = cv2.getTickCount()
t = (e2 - e1)/cv2.getTickFrequency()
print t
print( t )
# Result I got is 0.521107655 seconds
@endcode