Colorizing a Black & White image
You’ll see in this example the result of updating the color palette of an original color image by using CCTR color palette.
Original image |
Output |
---|---|
1from GameBEye.gbcamimage import gbcamimage
2from GameBEye.gbcamcolors.gbcamcolors import GBColorPalettes
3import cv2
4
5# Path to the image
6image_filepath = "images\\originalImage.png"
7img = cv2.imread(image_filepath)
8
9# Creation of an GCCamImage object
10gb_img = gbcamimage.GBCamImage()
11# Reading of the file
12gb_img.read(image_filepath)
13
14# Displaying the original image
15original_title = "Original image with {} color palette".format(
16 gb_img.color_palette.name
17)
18cv2.imshow(original_title, gb_img.data)
19print("Original color palette : {}".format(gb_img.color_palette))
20
21# Changing image color palette
22gb_color_palette = GBColorPalettes.AZC
23gb_img.change_color(color_palette=gb_color_palette)
24
25# Displaying the colorized image
26color_title = "Colorized image with {} color palette".format(
27 gb_img.color_palette.name
28)
29cv2.imshow(color_title, gb_img.data)
30print(
31 "Colorized image color palette : {}\nRequired color palette : {}".format(
32 gb_img.color_palette, gb_color_palette
33 )
34)
35
36cv2.waitKey()
37cv2.destroyWindow(original_title)
38cv2.destroyWindow(color_title)