티스토리 뷰
2개의 서로 다른 이미지가 있는 경우에,
1) 2개의 이미지를 같은 크기로 맞추고
2) 각 이미지에 상이한 투명도를 적용하여
3) 하나의 새로운 이미지를 만든다.
[원본 이미지]
![]() |
![]() |
[편집 이미지]
def MakeImagewithDifferentTransparency():
alpha = 0.2
imageFile1 = "./TestImage101.jpg"
imageFile2 = "./TestImage102.jpg"
image1 = cv2.imread(imageFile1, cv2.IMREAD_UNCHANGED)
image2 = cv2.imread(imageFile2, cv2.IMREAD_UNCHANGED)
if image1.size<image2.size:
refShape = image2.shape
image1 = cv2.resize(image1, (refShape[1], refShape[0] ), interpolation=cv2.INTER_CUBIC)
else:
refShape = image1.shape
image2 = cv2.resize(image2, (refShape[1], refShape[0] ), interpolation=cv2.INTER_CUBIC)
rstImage = np.zeros((refShape[0], refShape[1], 3), dtype=np.uint8)
for y in range(refShape[0]):
for x in range(refShape[1]):
# cvtPixel = cv2.addWeighted(image1[y, x], alpha, image2[y, x], 1-alpha, 0)
cvtPixel = image1[y, x]*alpha + image2[y, x]*(1-alpha)
rstImage[y, x] = cvtPixel
cv2.imwrite("./OutImage102.jpg", rstImage)
반응형
'SWDesk' 카테고리의 다른 글
[Python] 지메일 내용 가져오기 (0) | 2023.11.18 |
---|---|
[Python4BID] 동영상에 반투명으로 움직이는 PNG 입히기 (0) | 2023.11.05 |
[Python4BID] 이미지에 동영상 덮기 (0) | 2023.11.02 |
[Python4BID] 타일 형식의 이미지 만들기 (0) | 2023.11.02 |
[Python4BID] 이미지의 일부분을 투명하게 만드는 방법 (0) | 2023.11.02 |
반응형
250x250
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 치매방지
- ServantClock
- Video
- 혁신
- 허들
- 전류
- 아두이노
- DYOV
- 배프
- 치매
- 절연형
- 둎
- 전압
- image
- 전압전류모니터링
- 빌리언트
- badp
- 티스토리챌린지
- Decorator
- Innovation&Hurdles
- arduino
- bilient
- Innovations&Hurdles
- 심심풀이
- Hurdles
- 오블완
- BSC
- Innovations
- 혁신과허들
- 심심풀이치매방지기
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
글 보관함