python-FloatImg/tests/contrast.py

36 lines
1.2 KiB
Python

import floatimg
import logging
def test_square():
width, height = 5, 5
color = [127.0, 127.0, 127.0]
img = floatimg.create_rgb(width, height)
img.fill(color)
img.put(2, 2, [200, 200, 200])
result_dict = {
floatimg.Contrast.SQRT: (
[225.83180236816406, 225.83180236816406, 225.83180236816406],
[179.9583282470703, 179.9583282470703, 179.9583282470703],
),
floatimg.Contrast.POW2: (
[156.8627471923828, 156.8627471923828, 156.8627471923828],
[63.250980377197266, 63.250980377197266, 63.250980377197266],
),
floatimg.Contrast.COS01: (
[226.83277893066406, 226.83277893066406, 226.83277893066406],
[126.71460723876953, 126.71460723876953, 126.71460723876953],
),
floatimg.Contrast.COS010: (
[100.2235336303711, 100.2235336303711, 100.2235336303711],
[254.99032592773438, 254.99032592773438, 254.99032592773438],
),
}
for contrast_type, (center, outer) in result_dict.items():
res = img.contrast(255, contrast_type)
assert res.get(2, 2) == center
assert res.get(2, 3) == outer