-
Notifications
You must be signed in to change notification settings - Fork 11
/
save_image.py
36 lines (20 loc) · 957 Bytes
/
save_image.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#####################################################################
# Example : save an image from file (and invert it)
# Author : Toby Breckon, [email protected]
# Copyright (c) 2015 School of Engineering & Computing Science,
# Durham University, UK
# License : LGPL - http://www.gnu.org/licenses/lgpl.html
#####################################################################
import cv2
#####################################################################
# read an image from the specified file (in colour)
img = cv2.imread('example.jpg', cv2.IMREAD_COLOR)
# check it has loaded
if img is not None:
# performing logical inversion (see manual entry for bitwise_not ()
inverted = cv2.bitwise_not(img)
# write inverted image to file
cv2.imwrite("inverted.jpg", inverted)
else:
print("No image file successfully loaded.")
#####################################################################