import os import numpy as np import cv2 as cv def main(): # 画像を読み込む directory = os.path.dirname(__file__) image = cv.imread(os.path.join(directory, "image.jpg")) if image is None: exit() # マトリックス風カラー変換 # https://twitter.com/iquilezles/status/1440847977560494084 image = image.astype(np.float32) / 255.0 image = image ** (3.0 / 2.0, 4.0 / 5.0, 3.0 / 2.0) image = (image * 255.0).astype(np.uint8) # 画像を表示する cv.imshow("matrix color", image) cv.waitKey(0) cv.destroyAllWindows() if __name__ == '__main__': main()