📌
# bitwise 함수 : 2개의 이미지 호출하기
import numpy as np, cv2
image1 = np.zeros((300, 300), np.uint8) # 300행, 300열 검은색 영상 생성
image2 = image1.copy()
image1.shape
cv2.imshow("image1", image1)
cv2.imshow("image2", image2)
h, w = image1.shape[:2] # 300, 300
print(h, w)
cx, cy = w//2, h//2
print(cx, cy)
# 원을 표시.
# (cx, cy) : 원의 중심 좌표
# 100 : 반지름
# 255 : 색상값
cv2.circle(image1, (cx, cy), 100, 255, -1) # 중심에 원 그리기
# 사각형 표시
# (0, 0, cx, h) : (시작 x좌표, 시작 y좌표, w, h)
# 255 : 색상값
cv2.rectangle(image2, (0, 0, cx, h), 255, -1)
# 두개의 이미지 합하기
image3 = cv2.bitwise_or(image1, image2) # 원소 간 논리합
image4 = cv2.bitwise_and(image1, image2) # 원소 간 논리곱
image5 = cv2.bitwise_xor(image1, image2) # 원소 간 배타적 논리합
image6 = cv2.bitwise_not(image1) # 행렬 반전
cv2.imshow("bitwise_or", image3)
cv2.imshow("bitwise_and", image4)
cv2.imshow("bitwise_xor", image5)
cv2.imshow("bitwise_not", image6)
cv2.waitKey(0)

'수업(국비지원) > Python' 카테고리의 다른 글
| [Python] 딥러닝 - 가중치와 편향, 다중 퍼센트론 (0) | 2023.04.27 |
|---|---|
| [Python] 딥러닝 - 인공신경망(ANN) (0) | 2023.04.27 |
| [Python] 2개의 이미지 호출, 이미지에서 얼굴, 눈 표시하기 (0) | 2023.04.27 |
| [Python] 웹 숫자 예측 프로그램 만들기 환경설정 (0) | 2023.04.27 |
| [Python] 실제 숫자 이미지 처리하기 (0) | 2023.04.27 |