[ Python OpenCV ] 파이썬 오픈씨브이 이미지 색상 변환 그레이 스케일 - cv2.cvtColor
1. OpenCV 색상변환 함수
def cvtColor(src, code, dst=None, dstCn=None, /)
2. R, G 및 B 채널 값의 일반적인 범위
- CV_8U 이미지의 경우 0 ~ 255
- CV_16U 이미지의 경우 0 ~ 65535
- CV_32F 이미지의 경우 0:1
3. 그레이 스케일 변환
import cv2 as cv
# 이미지 경로
image = cv.imread('/home/heojungwook/VSCode
/cat.jpeg')
# 이미지 쇼 (Form Title Name)
cv.imshow('image', image)
# 이미지 그레이 변환
COLOR_BGR2GRAY = cv.cvtColor(image,
cv.COLOR_BGR2GRAY)
cv.imshow('COLOR_BGR2GRAY', COLOR_BGR2GRAY)
4. 색상 변환 전체 보기
COLOR_BGR2BGRA = cv.cvtColor(image,
cv.COLOR_BGR2BGRA)
cv.imshow('COLOR_BGR2BGRA', COLOR_BGR2BGRA)
COLOR_BGR2HLS = cv.cvtColor(image,
cv.COLOR_BGR2HLS)
cv.imshow('COLOR_BGR2HLS', COLOR_BGR2HLS)
COLOR_BGR2HLS_FULL = cv.cvtColor(image,
cv.COLOR_BGR2HLS_FULL)
cv.imshow('COLOR_BGR2HLS_FULL', COLOR_BGR2HLS_FULL)
COLOR_BGR2HSV = cv.cvtColor(image,
cv.COLOR_BGR2HSV)
cv.imshow('COLOR_BGR2HSV', COLOR_BGR2HSV)
COLOR_BGR2HSV_FULL = cv.cvtColor(image,
cv.COLOR_BGR2HSV_FULL)
cv.imshow('COLOR_BGR2HSV_FULL', COLOR_BGR2HSV_FULL)
COLOR_BGR2LAB = cv.cvtColor(image,
cv.COLOR_BGR2LAB)
cv.imshow('COLOR_BGR2LAB', COLOR_BGR2LAB)
COLOR_BGR2Lab = cv.cvtColor(image,
cv.COLOR_BGR2Lab)
cv.imshow('COLOR_BGR2Lab', COLOR_BGR2Lab)
COLOR_BGR2LUV = cv.cvtColor(image,
cv.COLOR_BGR2LUV)
cv.imshow('COLOR_BGR2LUV', COLOR_BGR2LUV)
COLOR_BGR2Luv = cv.cvtColor(image,
cv.COLOR_BGR2Luv)
cv.imshow('COLOR_BGR2Luv', COLOR_BGR2Luv)
COLOR_BGR2RGB = cv.cvtColor(image,
cv.COLOR_BGR2RGB)
cv.imshow('COLOR_BGR2RGB', COLOR_BGR2RGB)
COLOR_BGR2RGBA = cv.cvtColor(image,
cv.COLOR_BGR2RGBA)
cv.imshow('COLOR_BGR2RGBA', COLOR_BGR2RGBA)
COLOR_BGR2XYZ = cv.cvtColor(image,
cv.COLOR_BGR2XYZ)
cv.imshow('COLOR_BGR2XYZ', COLOR_BGR2XYZ)
COLOR_BGR2YCR_CB = cv.cvtColor(image,
cv.COLOR_BGR2YCR_CB)
cv.imshow('COLOR_BGR2YCR_CB', COLOR_BGR2YCR_CB)
COLOR_BGR2YCrCb = cv.cvtColor(image,
cv.COLOR_BGR2YCrCb)
cv.imshow('COLOR_BGR2YCrCb', COLOR_BGR2YCrCb)
COLOR_BGR2YUV = cv.cvtColor(image,
cv.COLOR_BGR2YUV)
cv.imshow('COLOR_BGR2YUV', COLOR_BGR2YUV)
5. YUV 컬러는 파이프라인의 일부로 사용되는 색 인코딩 시스템
COLOR_BGR2YUV_I420 = cv.cvtColor(image,
cv.COLOR_BGR2YUV_I420)
cv.imshow('COLOR_BGR2YUV_I420', COLOR_BGR2YUV_I420)
COLOR_BGR2YUV_IYUV = cv.cvtColor(image,
cv.COLOR_BGR2YUV_IYUV)
cv.imshow('COLOR_BGR2YUV_IYUV', COLOR_BGR2YUV_IYUV)
COLOR_BGR2YUV_YV12 = cv.cvtColor(image,
cv.COLOR_BGR2YUV_YV12)
cv.imshow('COLOR_BGR2YUV_YV12', COLOR_BGR2YUV_YV12)
==========
댓글
댓글 쓰기