当前位置:网站首页>[200 opencv routines by youcans] 201 Color space conversion of images
[200 opencv routines by youcans] 201 Color space conversion of images
2022-06-13 03:36:00 【Xiaobai youcans】
OpenCV routine 200 piece General catalogue
List of articles
【youcans Of OpenCV routine 200 piece 】201. Image color space conversion
Color space basis of image
Color space means through multiple ( Usually it is 3 Or 4 individual ) Color components constitute a coordinate system to represent the model system of various colors . Each pixel in the color space represents a color , The color of each pixel is the composition or description of multiple color components .
Color images can be mapped to a certain color space for description as needed . In different industrial environments or machine vision applications , Different color spaces are used .
Common color spaces include :GRAY Color space ( Grayscale image )、XYZ Color space 、YCrCb Color space 、HSV Color space 、HLS Color space 、CIELab Color space 、CIELuv Color space 、Bayer Color space, etc .
The computer display adopts RGB Color space , Digital art creation often adopts HSV/HSB Color space , Machine vision and image processing systems are widely used HSl、HSL Color space . The meanings of each color component are :
- RGB: Red (Red)、 green (Green)、 Blue (Blue);
- HSV/HSB: tonal (Hue)、 saturation (Saturation) And lightness (Value/Brightness);
- HSl: tonal (Hue)、 saturation (Saturation) And grayscale (Intensity);
- HSL: Including hues (Hue)、 saturation (Saturation) And brightness (Luminance/Lightness).
RGB The model is an additive color system , Color comes from red 、 green 、 The three primary colors of blue . be used for CRT Monitor 、 Digital scanner 、 On digital cameras and display devices , It is the most widely used color model at present .
Image color space conversion formula
RGB * \longleftrightarrow * GRAY
GRAY Represents a grayscale image , Usually refers to cv_8U grayscale , Yes 256 Gray scale :0-255.
RGB → GRAY: g r a y = 0.299 ∗ R + 0.587 ∗ G + 0.114 ∗ B gray = 0.299*R + 0.587*G + 0.114*B gray=0.299∗R+0.587∗G+0.114∗BRGB * \longleftrightarrow * HSV
V ← max ( R , G , B ) S ← { [ V − m i n ( R , G , B ) ] / V , V ≠ 0 0 , V = 0 H ← { 60 ( G − B ) / [ V − m i n ( R , G , B ) ] , V = R 120 + 60 ( B − R ) / [ V − m i n ( R , G , B ) ] , V = G 240 + 60 ( R − G ) / [ V − m i n ( R , G , B ) ] , V = B 0 , R = G = B \begin{aligned} V & \leftarrow \max{(R,G,B)} \\ S & \leftarrow \begin{cases} [{V-min{(R,G,B)}}]/V, &V \neq 0\\ 0, &V=0 \end{cases}\\ H &\leftarrow \begin{cases} 60(G-B)/[{V-min{(R,G,B)}}], &V =R\\ 120+60(B-R)/[{V-min{(R,G,B)}}], &V =G\\ 240+60(R-G)/[{V-min{(R,G,B)}}], &V =B\\ 0, & R=G=B \end{cases} \end{aligned} VSH←max(R,G,B)←{ [V−min(R,G,B)]/V,0,V=0V=0←⎩⎪⎪⎪⎨⎪⎪⎪⎧60(G−B)/[V−min(R,G,B)],120+60(B−R)/[V−min(R,G,B)],240+60(R−G)/[V−min(R,G,B)],0,V=RV=GV=BR=G=B
More color space conversion formulas , See OpenCV Official documents : OpenCV: Color conversions .
Image color space conversion
Color space type conversion , It refers to converting an image from one color space to another . for example , In the process of image feature extraction 、 When calculating the distance , Often the image is first removed from RGB Color space is converted to gray color space .
function cv.cvtColor() Convert an image from one color space to another .
cv.cvtColor(src, code [, dst, dstCn]]) → dst
Parameter description :
- src: The input image ,nparray Multidimensional arrays ,8 Bit unsigned / 16 Bit unsigned / Single precision floating point format
- code: Color space conversion code , See ColorConversionCodes
- dst: Output image , The size and depth are the same as src identical
- dstCn: Number of channels to output the image ,0 By src and code Automatic calculation .
matters needing attention :
- If you use RGB Representation , Clearly specify the order of each channel as RGB or BGR.
OpenCV,PyQt5 and Matplotlib We use RGB Models represent color images , The data format is Numpy Multidimensional arrays .
but OpenCV Medium is BGR The order , According to the blue / green / In red order ; and PyQt5、Matplotlib Medium is RGB Format , According to red / green / Sort in blue .
Therefore use plt.imshow() Show OpenCV Color images , First, color space conversion , send Numpy Multi dimensional array according to RGB Format sort .
PyQt5 Also used RGB Format , stay PyQt5 It shows that OpenCV Color images should also be converted to RGB Format . - Grayscale images are single channel , stay OpenCV and Matplotlib All of them are Numpy Two dimensional array .
- The pixel value range of each channel in the color image , And the pixel value range of the gray image , By the bit depth of the image pixel depth decision .
CV_8U yes 8 Bit unsigned format , Value range 0-255, This is the normal range for most image and video formats ;CV_16U yes 16 Bit unsigned format , Value range 0-65535;CV_32F Is a single precision floating-point format , Value range 0.0-1.0. - Image format conversion is usually linear transformation , The bit depth of the pixel does not affect the transformation result ; But in nonlinear calculation or transformation , Need to put RGB The input image is normalized to an appropriate value range , To get the right results .
- If you use 8 Bit unsigned format CV_8U, Some information may be lost due to low data accuracy , Use 16 Bit or 32 Bit data format can solve this problem .
- If... Is added after conversion alpha passageway ,alpha The value of the channel is the maximum value of the corresponding channel range ,CV_8U The image is 255,CV_16U The image is 65535,CV_32F The image is 1.0.
- This function converts the image from GRAY Convert to RGB when , The conversion rule is :R=G=B=gray .
routine 14.1:OpenCV Color space conversion type
# 14.1 OpenCV Color space conversion type
flags = [i for i in dir(cv) if i.startswith('COLOR_')]
print(flags)
function cv.cvtColor Provides 150 Multiple color space conversion types , This routine can query OpenCV Supported color conversion types .
Running results :
[‘COLOR_BAYER_BG2BGR’, ‘COLOR_BAYER_BG2BGRA’, ‘COLOR_BAYER_BG2BGR_EA’, ‘COLOR_BAYER_BG2BGR_VNG’, ‘COLOR_BAYER_BG2GRAY’, ‘COLOR_BAYER_BG2RGB’, ‘COLOR_BAYER_BG2RGBA’, ‘COLOR_BAYER_BG2RGB_EA’, ‘COLOR_BAYER_BG2RGB_VNG’, ‘COLOR_BAYER_BGGR2BGR’, ‘COLOR_BAYER_BGGR2BGRA’, ‘COLOR_BAYER_BGGR2BGR_EA’, ‘COLOR_BAYER_BGGR2BGR_VNG’, ‘COLOR_BAYER_BGGR2GRAY’, ‘COLOR_BAYER_BGGR2RGB’, ‘COLOR_BAYER_BGGR2RGBA’, ‘COLOR_BAYER_BGGR2RGB_EA’, ‘COLOR_BAYER_BGGR2RGB_VNG’, ‘COLOR_BAYER_GB2BGR’, ‘COLOR_BAYER_GB2BGRA’, ‘COLOR_BAYER_GB2BGR_EA’, ‘COLOR_BAYER_GB2BGR_VNG’, ‘COLOR_BAYER_GB2GRAY’, ‘COLOR_BAYER_GB2RGB’, ‘COLOR_BAYER_GB2RGBA’, ‘COLOR_BAYER_GB2RGB_EA’, ‘COLOR_BAYER_GB2RGB_VNG’, ‘COLOR_BAYER_GBRG2BGR’, ‘COLOR_BAYER_GBRG2BGRA’, ‘COLOR_BAYER_GBRG2BGR_EA’, ‘COLOR_BAYER_GBRG2BGR_VNG’, ‘COLOR_BAYER_GBRG2GRAY’, ‘COLOR_BAYER_GBRG2RGB’, ‘COLOR_BAYER_GBRG2RGBA’, ‘COLOR_BAYER_GBRG2RGB_EA’, ‘COLOR_BAYER_GBRG2RGB_VNG’, ‘COLOR_BAYER_GR2BGR’, ‘COLOR_BAYER_GR2BGRA’, ‘COLOR_BAYER_GR2BGR_EA’, ‘COLOR_BAYER_GR2BGR_VNG’, ‘COLOR_BAYER_GR2GRAY’, ‘COLOR_BAYER_GR2RGB’, ‘COLOR_BAYER_GR2RGBA’, ‘COLOR_BAYER_GR2RGB_EA’, ‘COLOR_BAYER_GR2RGB_VNG’, ‘COLOR_BAYER_GRBG2BGR’, ‘COLOR_BAYER_GRBG2BGRA’, ‘COLOR_BAYER_GRBG2BGR_EA’, ‘COLOR_BAYER_GRBG2BGR_VNG’, ‘COLOR_BAYER_GRBG2GRAY’, ‘COLOR_BAYER_GRBG2RGB’, ‘COLOR_BAYER_GRBG2RGBA’, ‘COLOR_BAYER_GRBG2RGB_EA’, ‘COLOR_BAYER_GRBG2RGB_VNG’, ‘COLOR_BAYER_RG2BGR’, ‘COLOR_BAYER_RG2BGRA’, ‘COLOR_BAYER_RG2BGR_EA’, ‘COLOR_BAYER_RG2BGR_VNG’, ‘COLOR_BAYER_RG2GRAY’, ‘COLOR_BAYER_RG2RGB’, ‘COLOR_BAYER_RG2RGBA’, ‘COLOR_BAYER_RG2RGB_EA’, ‘COLOR_BAYER_RG2RGB_VNG’, ‘COLOR_BAYER_RGGB2BGR’, ‘COLOR_BAYER_RGGB2BGRA’, ‘COLOR_BAYER_RGGB2BGR_EA’, ‘COLOR_BAYER_RGGB2BGR_VNG’, ‘COLOR_BAYER_RGGB2GRAY’, ‘COLOR_BAYER_RGGB2RGB’, ‘COLOR_BAYER_RGGB2RGBA’, ‘COLOR_BAYER_RGGB2RGB_EA’, ‘COLOR_BAYER_RGGB2RGB_VNG’, ‘COLOR_BGR2BGR555’, ‘COLOR_BGR2BGR565’, ‘COLOR_BGR2BGRA’, ‘COLOR_BGR2GRAY’, ‘COLOR_BGR2HLS’, ‘COLOR_BGR2HLS_FULL’, ‘COLOR_BGR2HSV’, ‘COLOR_BGR2HSV_FULL’, ‘COLOR_BGR2LAB’, ‘COLOR_BGR2LUV’, ‘COLOR_BGR2Lab’, ‘COLOR_BGR2Luv’, ‘COLOR_BGR2RGB’, ‘COLOR_BGR2RGBA’, ‘COLOR_BGR2XYZ’, ‘COLOR_BGR2YCR_CB’, ‘COLOR_BGR2YCrCb’, ‘COLOR_BGR2YUV’, ‘COLOR_BGR2YUV_I420’, ‘COLOR_BGR2YUV_IYUV’, ‘COLOR_BGR2YUV_YV12’, ‘COLOR_BGR5552BGR’, ‘COLOR_BGR5552BGRA’, ‘COLOR_BGR5552GRAY’, ‘COLOR_BGR5552RGB’, ‘COLOR_BGR5552RGBA’, ‘COLOR_BGR5652BGR’, ‘COLOR_BGR5652BGRA’, ‘COLOR_BGR5652GRAY’, ‘COLOR_BGR5652RGB’, ‘COLOR_BGR5652RGBA’, ‘COLOR_BGRA2BGR’, ‘COLOR_BGRA2BGR555’, ‘COLOR_BGRA2BGR565’, ‘COLOR_BGRA2GRAY’, ‘COLOR_BGRA2RGB’, ‘COLOR_BGRA2RGBA’, ‘COLOR_BGRA2YUV_I420’, ‘COLOR_BGRA2YUV_IYUV’, ‘COLOR_BGRA2YUV_YV12’, ‘COLOR_BayerBG2BGR’, ‘COLOR_BayerBG2BGRA’, ‘COLOR_BayerBG2BGR_EA’, ‘COLOR_BayerBG2BGR_VNG’, ‘COLOR_BayerBG2GRAY’, ‘COLOR_BayerBG2RGB’, ‘COLOR_BayerBG2RGBA’, ‘COLOR_BayerBG2RGB_EA’, ‘COLOR_BayerBG2RGB_VNG’, ‘COLOR_BayerBGGR2BGR’, ‘COLOR_BayerBGGR2BGRA’, ‘COLOR_BayerBGGR2BGR_EA’, ‘COLOR_BayerBGGR2BGR_VNG’, ‘COLOR_BayerBGGR2GRAY’, ‘COLOR_BayerBGGR2RGB’, ‘COLOR_BayerBGGR2RGBA’, ‘COLOR_BayerBGGR2RGB_EA’, ‘COLOR_BayerBGGR2RGB_VNG’, ‘COLOR_BayerGB2BGR’, ‘COLOR_BayerGB2BGRA’, ‘COLOR_BayerGB2BGR_EA’, ‘COLOR_BayerGB2BGR_VNG’, ‘COLOR_BayerGB2GRAY’, ‘COLOR_BayerGB2RGB’, ‘COLOR_BayerGB2RGBA’, ‘COLOR_BayerGB2RGB_EA’, ‘COLOR_BayerGB2RGB_VNG’, ‘COLOR_BayerGBRG2BGR’, ‘COLOR_BayerGBRG2BGRA’, ‘COLOR_BayerGBRG2BGR_EA’, ‘COLOR_BayerGBRG2BGR_VNG’, ‘COLOR_BayerGBRG2GRAY’, ‘COLOR_BayerGBRG2RGB’, ‘COLOR_BayerGBRG2RGBA’, ‘COLOR_BayerGBRG2RGB_EA’, ‘COLOR_BayerGBRG2RGB_VNG’, ‘COLOR_BayerGR2BGR’, ‘COLOR_BayerGR2BGRA’, ‘COLOR_BayerGR2BGR_EA’, ‘COLOR_BayerGR2BGR_VNG’, ‘COLOR_BayerGR2GRAY’, ‘COLOR_BayerGR2RGB’, ‘COLOR_BayerGR2RGBA’, ‘COLOR_BayerGR2RGB_EA’, ‘COLOR_BayerGR2RGB_VNG’, ‘COLOR_BayerGRBG2BGR’, ‘COLOR_BayerGRBG2BGRA’, ‘COLOR_BayerGRBG2BGR_EA’, ‘COLOR_BayerGRBG2BGR_VNG’, ‘COLOR_BayerGRBG2GRAY’, ‘COLOR_BayerGRBG2RGB’, ‘COLOR_BayerGRBG2RGBA’, ‘COLOR_BayerGRBG2RGB_EA’, ‘COLOR_BayerGRBG2RGB_VNG’, ‘COLOR_BayerRG2BGR’, ‘COLOR_BayerRG2BGRA’, ‘COLOR_BayerRG2BGR_EA’, ‘COLOR_BayerRG2BGR_VNG’, ‘COLOR_BayerRG2GRAY’, ‘COLOR_BayerRG2RGB’, ‘COLOR_BayerRG2RGBA’, ‘COLOR_BayerRG2RGB_EA’, ‘COLOR_BayerRG2RGB_VNG’, ‘COLOR_BayerRGGB2BGR’, ‘COLOR_BayerRGGB2BGRA’, ‘COLOR_BayerRGGB2BGR_EA’, ‘COLOR_BayerRGGB2BGR_VNG’, ‘COLOR_BayerRGGB2GRAY’, ‘COLOR_BayerRGGB2RGB’, ‘COLOR_BayerRGGB2RGBA’, ‘COLOR_BayerRGGB2RGB_EA’, ‘COLOR_BayerRGGB2RGB_VNG’, ‘COLOR_COLORCVT_MAX’, ‘COLOR_GRAY2BGR’, ‘COLOR_GRAY2BGR555’, ‘COLOR_GRAY2BGR565’, ‘COLOR_GRAY2BGRA’, ‘COLOR_GRAY2RGB’, ‘COLOR_GRAY2RGBA’, ‘COLOR_HLS2BGR’, ‘COLOR_HLS2BGR_FULL’, ‘COLOR_HLS2RGB’, ‘COLOR_HLS2RGB_FULL’, ‘COLOR_HSV2BGR’, ‘COLOR_HSV2BGR_FULL’, ‘COLOR_HSV2RGB’, ‘COLOR_HSV2RGB_FULL’, ‘COLOR_LAB2BGR’, ‘COLOR_LAB2LBGR’, ‘COLOR_LAB2LRGB’, ‘COLOR_LAB2RGB’, ‘COLOR_LBGR2LAB’, ‘COLOR_LBGR2LUV’, ‘COLOR_LBGR2Lab’, ‘COLOR_LBGR2Luv’, ‘COLOR_LRGB2LAB’, ‘COLOR_LRGB2LUV’, ‘COLOR_LRGB2Lab’, ‘COLOR_LRGB2Luv’, ‘COLOR_LUV2BGR’, ‘COLOR_LUV2LBGR’, ‘COLOR_LUV2LRGB’, ‘COLOR_LUV2RGB’, ‘COLOR_Lab2BGR’, ‘COLOR_Lab2LBGR’, ‘COLOR_Lab2LRGB’, ‘COLOR_Lab2RGB’, ‘COLOR_Luv2BGR’, ‘COLOR_Luv2LBGR’, ‘COLOR_Luv2LRGB’, ‘COLOR_Luv2RGB’, ‘COLOR_M_RGBA2RGBA’, ‘COLOR_RGB2BGR’, ‘COLOR_RGB2BGR555’, ‘COLOR_RGB2BGR565’, ‘COLOR_RGB2BGRA’, ‘COLOR_RGB2GRAY’, ‘COLOR_RGB2HLS’, ‘COLOR_RGB2HLS_FULL’, ‘COLOR_RGB2HSV’, ‘COLOR_RGB2HSV_FULL’, ‘COLOR_RGB2LAB’, ‘COLOR_RGB2LUV’, ‘COLOR_RGB2Lab’, ‘COLOR_RGB2Luv’, ‘COLOR_RGB2RGBA’, ‘COLOR_RGB2XYZ’, ‘COLOR_RGB2YCR_CB’, ‘COLOR_RGB2YCrCb’, ‘COLOR_RGB2YUV’, ‘COLOR_RGB2YUV_I420’, ‘COLOR_RGB2YUV_IYUV’, ‘COLOR_RGB2YUV_YV12’, ‘COLOR_RGBA2BGR’, ‘COLOR_RGBA2BGR555’, ‘COLOR_RGBA2BGR565’, ‘COLOR_RGBA2BGRA’, ‘COLOR_RGBA2GRAY’, ‘COLOR_RGBA2M_RGBA’, ‘COLOR_RGBA2RGB’, ‘COLOR_RGBA2YUV_I420’, ‘COLOR_RGBA2YUV_IYUV’, ‘COLOR_RGBA2YUV_YV12’, ‘COLOR_RGBA2mRGBA’, ‘COLOR_XYZ2BGR’, ‘COLOR_XYZ2RGB’, ‘COLOR_YCR_CB2BGR’, ‘COLOR_YCR_CB2RGB’, ‘COLOR_YCrCb2BGR’, ‘COLOR_YCrCb2RGB’, ‘COLOR_YUV2BGR’, ‘COLOR_YUV2BGRA_I420’, ‘COLOR_YUV2BGRA_IYUV’, ‘COLOR_YUV2BGRA_NV12’, ‘COLOR_YUV2BGRA_NV21’, ‘COLOR_YUV2BGRA_UYNV’, ‘COLOR_YUV2BGRA_UYVY’, ‘COLOR_YUV2BGRA_Y422’, ‘COLOR_YUV2BGRA_YUNV’, ‘COLOR_YUV2BGRA_YUY2’, ‘COLOR_YUV2BGRA_YUYV’, ‘COLOR_YUV2BGRA_YV12’, ‘COLOR_YUV2BGRA_YVYU’, ‘COLOR_YUV2BGR_I420’, ‘COLOR_YUV2BGR_IYUV’, ‘COLOR_YUV2BGR_NV12’, ‘COLOR_YUV2BGR_NV21’, ‘COLOR_YUV2BGR_UYNV’, ‘COLOR_YUV2BGR_UYVY’, ‘COLOR_YUV2BGR_Y422’, ‘COLOR_YUV2BGR_YUNV’, ‘COLOR_YUV2BGR_YUY2’, ‘COLOR_YUV2BGR_YUYV’, ‘COLOR_YUV2BGR_YV12’, ‘COLOR_YUV2BGR_YVYU’, ‘COLOR_YUV2GRAY_420’, ‘COLOR_YUV2GRAY_I420’, ‘COLOR_YUV2GRAY_IYUV’, ‘COLOR_YUV2GRAY_NV12’, ‘COLOR_YUV2GRAY_NV21’, ‘COLOR_YUV2GRAY_UYNV’, ‘COLOR_YUV2GRAY_UYVY’, ‘COLOR_YUV2GRAY_Y422’, ‘COLOR_YUV2GRAY_YUNV’, ‘COLOR_YUV2GRAY_YUY2’, ‘COLOR_YUV2GRAY_YUYV’, ‘COLOR_YUV2GRAY_YV12’, ‘COLOR_YUV2GRAY_YVYU’, ‘COLOR_YUV2RGB’, ‘COLOR_YUV2RGBA_I420’, ‘COLOR_YUV2RGBA_IYUV’, ‘COLOR_YUV2RGBA_NV12’, ‘COLOR_YUV2RGBA_NV21’, ‘COLOR_YUV2RGBA_UYNV’, ‘COLOR_YUV2RGBA_UYVY’, ‘COLOR_YUV2RGBA_Y422’, ‘COLOR_YUV2RGBA_YUNV’, ‘COLOR_YUV2RGBA_YUY2’, ‘COLOR_YUV2RGBA_YUYV’, ‘COLOR_YUV2RGBA_YV12’, ‘COLOR_YUV2RGBA_YVYU’, ‘COLOR_YUV2RGB_I420’, ‘COLOR_YUV2RGB_IYUV’, ‘COLOR_YUV2RGB_NV12’, ‘COLOR_YUV2RGB_NV21’, ‘COLOR_YUV2RGB_UYNV’, ‘COLOR_YUV2RGB_UYVY’, ‘COLOR_YUV2RGB_Y422’, ‘COLOR_YUV2RGB_YUNV’, ‘COLOR_YUV2RGB_YUY2’, ‘COLOR_YUV2RGB_YUYV’, ‘COLOR_YUV2RGB_YV12’, ‘COLOR_YUV2RGB_YVYU’, ‘COLOR_YUV420P2BGR’, ‘COLOR_YUV420P2BGRA’, ‘COLOR_YUV420P2GRAY’, ‘COLOR_YUV420P2RGB’, ‘COLOR_YUV420P2RGBA’, ‘COLOR_YUV420SP2BGR’, ‘COLOR_YUV420SP2BGRA’, ‘COLOR_YUV420SP2GRAY’, ‘COLOR_YUV420SP2RGB’, ‘COLOR_YUV420SP2RGBA’, ‘COLOR_YUV420p2BGR’, ‘COLOR_YUV420p2BGRA’, ‘COLOR_YUV420p2GRAY’, ‘COLOR_YUV420p2RGB’, ‘COLOR_YUV420p2RGBA’, ‘COLOR_YUV420sp2BGR’, ‘COLOR_YUV420sp2BGRA’, ‘COLOR_YUV420sp2GRAY’, ‘COLOR_YUV420sp2RGB’, ‘COLOR_YUV420sp2RGBA’, ‘COLOR_mRGBA2RGBA’]
routine 14.2: Color space conversion
# 14.2 OpenCV Color space conversion type
# Read the original image
imgBGR = cv.imread("../images/imgLena.tif", flags=1) # Read as BGR Color images
print(imgBGR.shape)
imgRGB = cv.cvtColor(imgBGR, cv.COLOR_BGR2RGB) # BGR Convert to RGB, be used for PyQt5, matplotlib
imgGRAY = cv.cvtColor(imgBGR, cv.COLOR_BGR2GRAY) # BGR Convert to grayscale image
imgHSV = cv.cvtColor(imgBGR, cv.COLOR_BGR2HSV) # BGR Convert to HSV Images
imgYCrCb = cv.cvtColor(imgBGR, cv.COLOR_BGR2YCrCb) # BGR turn YCrCb
imgHLS = cv.cvtColor(imgBGR, cv.COLOR_BGR2HLS) # BGR turn HLS Images
imgXYZ = cv.cvtColor(imgBGR, cv.COLOR_BGR2XYZ) # BGR turn XYZ Images
imgLAB = cv.cvtColor(imgBGR, cv.COLOR_BGR2LAB) # BGR turn LAB Images
imgYUV = cv.cvtColor(imgBGR, cv.COLOR_BGR2YUV) # BGR turn YUV Images
# call matplotlib Display processing results
titles = ['BGR', 'RGB', 'GRAY', 'HSV', 'YCrCb', 'HLS', 'XYZ', 'LAB', 'YUV']
images = [imgBGR, imgRGB, imgGRAY, imgHSV, imgYCrCb,
imgHLS, imgXYZ, imgLAB, imgYUV]
plt.figure(figsize=(10, 8))
for i in range(9):
plt.subplot(3, 3, i + 1), plt.imshow(images[i], 'gray')
plt.title(titles[i])
plt.xticks([]), plt.yticks([])
plt.tight_layout()
plt.show()
【 At the end of this section 】
Copyright notice :
[email protected] Original works , Reprint must be marked with the original link :(https://blog.csdn.net/youcans/article/details/125248543)
Copyright 2022 youcans, XUPT
Crated:2022-6-12
Welcome to your attention 『youcans Of OpenCV routine 200 piece 』 series , Ongoing update
Welcome to your attention 『youcans Of OpenCV Learning lessons 』 series , Ongoing update
边栏推荐
- Configuration and practice of shardingsphere JDBC sub database separation of read and write
- DDL operation table
- MySQL and PostgreSQL installation subtotal
- PostgreSQL common SQL
- Parallel one degree relation query
- Domestic zynq standalone pl-ps interrupt commissioning
- Scala sets (array, list, set, map, tuple, option)
- 2000-2019 enterprise registration data of all provinces, cities and counties in China (including longitude and latitude, registration number and other multi indicator information)
- (9) Explain broadcasting mechanism in detail
- On the career crisis of programmers at the age of 35
猜你喜欢
Understand the difference between reducebykey and groupbykey in spark
Peking University HP financial index - matching enterprise green innovation index 2011-2020: enterprise name, year, industry classification and other multi indicator data
LVS四层负载均衡集群(5)LVS概述
Masa Auth - SSO and Identity Design
Coal industry database - coal price, consumption, power generation & Provincial Civil and industrial power consumption data
Masa auth - SSO and identity design
A data modeling optimization solution for graph data super nodes
Onnx+tensorrt+yolov5: yolov5 deployment based on trt+onnx 1
Graph data modeling tool
Alibaba cloud OSS access notes
随机推荐
MySQL learning summary Xi: detailed explanation of the use of stored procedures and stored functions
2000-2019 enterprise registration data of all provinces, cities and counties in China (including longitude and latitude, registration number and other multi indicator information)
KITTI数据集无法下载的解决方法
C language programming - input a string arbitrarily from the keyboard, calculate the actual number of characters and print out. It is required that the string processing function strlen() cannot be us
MMAP usage in golang
The use of curl in PHP
English grammar_ Frequency adverb
Three ways of scala string interpolation
Union, intersection and difference sets of different MySQL databases
MASA Auth - 从用户的角度看整体设计
Dish recommendation system based on graph database
Several common ways for Flink to extract eventtime and generate watermark
Age anxiety? How to view the 35 year old programmer career crisis?
Azure SQL db/dw series (12) -- using query store (1) -- report Introduction (1)
How to Draw Useful Technical Architecture Diagrams
(九)详解广播机制
产品需求文档如何编写
年金险产品保险期满之后能领多少钱?
LVS四层负载均衡集群(6)LVS工作模式
Data from the first to seventh census (to counties)