Qiita Teams that are logged in
You are not logged in to any team

Community
Service
Qiita JobsQiita ZineQiita Blog
1
Help us understand the problem. What is going on with this article?
@MuAuan

# 【画像合成】OpenCVで元絵とGuided_BackPropagationの画像合成♪

More than 1 year has passed since last update.

【画像合成】OpenCVで積算によりノイズ除去をやってみた♪
【参考】
Arithmetic Operations on Images@OpenCV

### コードは以下のとおり

img1とimg2を入力キーの割合で合成します。6以外の時の合成画像はおまけに置きました。

``````import cv2
import matplotlib.pyplot as plt

rows,cols,channels = img2.shape
roi = img1[0:rows, 0:cols ]
cv2.imshow('org1',img1)
cv2.imshow('org2',img2)
cv2.waitKey(0)
cv2.destroyAllWindows()
a =1
k=0
while True:
cv2.imshow('dst',dst)
k=cv2.waitKey(0)&0xff
if k ==ord('q'):
cv2.imwrite('results'+str(a)+'.jpg',dst)
break
elif k ==ord('1'):
a = 0.1
elif k ==ord('2'):
a = 0.2
elif k ==ord('3'):
a = 0.3
elif k ==ord('4'):
a = 0.4
elif k ==ord('5'):
a = 0.5
elif k ==ord('6'):
a = 0.6
elif k ==ord('7'):
a = 0.7
elif k ==ord('8'):
a = 0.8
elif k ==ord('9'):
a = 0.9
elif k ==ord('0'):
a = 1
cv2.destroyAllWindows()
``````

### 結果

キーを１～１０まで変えると以下のとおりになりました。

### 画素の積(bitwise_and)

``````import cv2
import matplotlib.pyplot as plt

rows,cols,channels = img2.shape
roi = img1[0:rows, 0:cols ]
cv2.imshow('org1',img1)
cv2.imshow('org2',img2)
cv2.waitKey(0)
cv2.destroyAllWindows()
a =1
k=0
while True:
cv2.imshow('dst',dst)
k=cv2.waitKey(0)&0xff
if k ==ord('q'):
plt.imshow(dst)
#cv2.imwrite('results_multiply'+str(a)+'.jpg',dst)
plt.savefig('results_multiply'+str(a)+'.jpg')
plt.pause(1)
plt.close()
break
elif k ==ord('1'):
a = 0.1
elif k ==ord('2'):
a = 0.2
elif k ==ord('3'):
a = 0.3
elif k ==ord('4'):
a = 0.4
elif k ==ord('5'):
a = 0.5
elif k ==ord('6'):
a = 0.6
elif k ==ord('7'):
a = 0.7
elif k ==ord('8'):
a = 0.8
elif k ==ord('9'):
a = 0.9
elif k ==ord('g'):
a = 0.95
elif k ==ord('0'):
a = 1
cv2.destroyAllWindows()
``````

### まとめ

・どの程度の比で合成するか迷ってましたが、簡単に合成できました
・画素の積は完成度低いですが、まあここから一工夫で使えそうです

・本論はも少し実験重ねてから、次回まとめます

### おまけ

1
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
1. We will deliver articles that match you
By following users and tags, you can catch up information on technical fields that you are interested in as a whole
2. you can read useful information later efficiently
By "stocking" the articles you like, you can search right away
2021年為になる記事にする 記事420いいね2000フォロワー200 2020年；いい記事を書く 記事359/350いいね1590/1500フォロワ ー144/150 2019年 記事275／300いいね1035／1000フォロワー97／100 2018年 記事140／200いいね423／500フォロワー48／50 7/8/2018 記事90いいね227フォロワー25