0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

任意の色をくり抜いて画像を合成する方法 2(仮)

Last updated at Posted at 2021-06-09

※画像が多いです

今回はこれと

weather_report_for_test.png
これを組み合わせて

weather_material_FF0000.png

weather_mixed.png

これを作ります。(日本の形が変なのは許してください。)
python、pillow、opencv、そしてnumpyを使います。

def mixTest():
    material = cv2.imread("./resources/weather_material_FF0000.png")
    bgrLower = np.array([0, 0, 255])
    bgrUpper = np.array([0, 0, 255])

    # 抜き出す色は白に、それ以外は黒になる。
    MonoMask = cv2.inRange(material, bgrLower, bgrUpper)
    cv2.imwrite("./resources/mask.png", MonoMask)

    orImg = Image.open("./resources/weather_report_for_test.png").convert("RGBA")
    mrImg = Image.open("./resources/weather_material_FF0000.png").convert("RGBA")
    msImg = Image.open("./resources/mask.png").convert("L")
    im = Image.composite(orImg, mrImg, msImg)
    im.show()
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?