--The created image processing algorithm often verifies the effect with a test image. [^ 1] --In some cases, it may be more effective at the initial stage of verification to use a simpler pattern than a natural image, such as when you want to verify the calculation result of an algorithm with fine numerical values. [^ 1]: [lena --wikipedia](https://ja.wikipedia.org/wiki/%E3%83%AC%E3%83%8A_(%E7%94%BB%E5%83%8F%E3) % 83% 87% E3% 83% BC% E3% 82% BF)) is often used
--For example, it is a checker pattern or a test pattern used for broadcasting. [^ 2] [^ 2]: [Test pattern (broadcast) --wikipedia](https://ja.wikipedia.org/wiki/%E3%83%86%E3%82%B9%E3%83%88%E3%83% 91% E3% 82% BF% E3% 83% BC% E3% 83% B3_ (% E6% 94% BE% E9% 80% 81)) --So I wrote the code using Python and OpenCV. (Almost personal memorandum)
$python --version
Python 3.8.2
$pip list
Package Version
------------- --------
numpy 1.18.3
opencv-python 4.2.0.34
pip 20.0.2
setuptools 46.1.3
wheel 0.34.2
Sample code to generate grayscale and color bars
import cv2
import numpy as np
from enum import Enum
def gray_scale_chart():
width = 1920
height = 1080
gray_img = np.zeros((height,width), dtype=np.uint8)
val = 0
bar_width = 120
step = 17
for i in range(0, width, bar_width):
gray_img[0:height,i:i+bar_width]=val
val += step
cv2.imwrite("gray_scale.bmp", gray_img)
class Color(Enum):
WHITE=(255,255,255)
YELLOW=(0,255,255)
CYAN=(255,255,0)
GREEN=(0,255,0)
MAGENTA=(255,0,255)
RED=(0,0,255)
BLUE=(255,0,0)
BLACK=(0,0,0)
def full_color_bar():
width = 1920
height = 1080
color_img = np.zeros((height,width,3), dtype=np.uint8)
bar_width = 240
i = 0
for c in Color:
color_img[0:height,i:i+bar_width]=c.value
i += bar_width
cv2.imwrite("full_color_bar.bmp",color_img)
if __name__=='__main__':
gray_scale_chart()
full_color_bar()
Please check your monitor
Recommended Posts