CN106973277B - A kind of rgb format image turns the method and device of YUV420 format - Google Patents

A kind of rgb format image turns the method and device of YUV420 format Download PDF

Info

Publication number
CN106973277B
CN106973277B CN201710174818.9A CN201710174818A CN106973277B CN 106973277 B CN106973277 B CN 106973277B CN 201710174818 A CN201710174818 A CN 201710174818A CN 106973277 B CN106973277 B CN 106973277B
Authority
CN
China
Prior art keywords
color component
pixels
blocks
pixel
component
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710174818.9A
Other languages
Chinese (zh)
Other versions
CN106973277A (en
Inventor
位凯志
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sangfor Technologies Co Ltd
Original Assignee
Sangfor Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Sangfor Technologies Co Ltd filed Critical Sangfor Technologies Co Ltd
Priority to CN201710174818.9A priority Critical patent/CN106973277B/en
Publication of CN106973277A publication Critical patent/CN106973277A/en
Application granted granted Critical
Publication of CN106973277B publication Critical patent/CN106973277B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N9/00Details of colour television systems
    • H04N9/64Circuits for processing colour signals
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N9/00Details of colour television systems
    • H04N9/64Circuits for processing colour signals
    • H04N9/68Circuits for processing colour signals for controlling the amplitude of colour signals, e.g. automatic chroma control circuits
    • H04N9/69Circuits for processing colour signals for controlling the amplitude of colour signals, e.g. automatic chroma control circuits for modifying the colour signals by gamma correction

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Processing Of Color Television Signals (AREA)
  • Image Processing (AREA)

Abstract

The method that rgb format image provided by the invention turns YUV420 format, the blocks of pixels for being multiple 2*2 by rgb format image segmentation to be processed;By the R of pixel each in each blocks of pixels, G, B color component is mapped to linear space, the average value of each color component is sought in linear space, and each average value is mapped in 0~255 range of corresponding color component, obtain the R of each blocks of pixels, G, B corrects color component, it avoids in the prior art, since the value of each color component is not transformed into linear space, but directly the color component of pixel each in blocks of pixels is added to be averaging or fix, some pixel is selected to do sampled point, cause under VDI environment picture Key detail problem easy to be lost in CAD scene.Then the U component and V component that each blocks of pixels is calculated separately further according to R, G, B amendment color component, finally combine Y-component, obtain the image of YUV420 format, improve the display effect of image.

Description

A kind of rgb format image turns the method and device of YUV420 format
Technical field
The present invention relates to image format conversion technical fields, more particularly to a kind of rgb format image turns YUV420 lattice The method and device of formula.
Background technique
With the development of server and network, desktop virtual technology using more and more extensive, still, in extension process In, virtualization technology also brings some new problems, especially shows in terms of the support to computer aided design software It is particularly evident.
It is well known that computer aided design software is related to the complex works such as largely calculating, render, it is aobvious to generally require profession Card is supported, such as the M4000 of NVIDIA (Chinese: tall and handsome to reach).VDI (full name in English: VirtualDesktop Infrastructure) it is a kind of server- based computing model, is that the Remote Dynamic of the realization desktop system of enterprise-level is visited Ask the scheme for supporting computer aided design software that video card is generally used to virtualize with data center's trustship technology, VDI, it is main at present The video card virtualization scheme of stream is divided into hardware virtualization and GPU is shared.
Either using the scheme of the shared still GPU hardware virtualization of GPU, how is the image after will solving GPU rendering The problem of transmission comes out, the image that Effective Pictures By A Computer comes out, mostly uses greatly sRGB standard, and RGB24 and RGB32 are its mainstreams Rendering after image storage format, current VMWARE, Huawei, Citrix substantially use the encoding scheme based on H264, When carrying out H264 coding, first have to rgb format is converted to YUV420 format.
The method that existing rgb format is converted to YUV420 format, under VDI environment, in CAD scene Picture Key detail is easy to be lost, and display effect is poor.
Summary of the invention
In view of this, the present invention provides the method and devices that a kind of rgb format image turns YUV420 format, by each picture Each color component of each pixel, is mapped to linear space, then be averaging in plain piecemeal, and by average value inverse mapping to accordingly Color component 0~255 range in, obtain each amendment color component of each blocks of pixels, avoid area of computer aided The problem of picture Key detail is lost in design scenario, improves display effect.
Specific technical solution is as follows:
A kind of method that rgb format image turns YUV420 format, comprising:
The blocks of pixels for being multiple 2*2 by rgb format image segmentation to be processed;
R, G, B of the coefficient according to as defined in preset standard and each pixel in the rgb format image to be processed Color component calculates the Y-component of each pixel;
R, G, B color component of each pixel in each described blocks of pixels are mapped to linear space respectively, online The average value of each color component in each blocks of pixels is sought in property space respectively, and each average value is mapped to In 0~255 range of corresponding color component, R, G, B amendment color component of each blocks of pixels are respectively obtained;
Color component is corrected according to coefficient as defined in the preset standard and R, G, B of each blocks of pixels, point The U component and V component for not calculating each blocks of pixels obtain YUV420 format in conjunction with the Y-component of each pixel Image.
Preferably, when the rgb format image to be processed is RGB32 format, described by rgb format to be processed Image segmentation is the blocks of pixels of multiple 2*2, before further include:
RGB24 format-pattern is converted by RGB32 format-pattern to be processed.
Preferably, described that R, G, B color component of each pixel in each described blocks of pixels are mapped to line respectively Property space, comprising:
Respectively by R, G, B color component of each pixel in each described blocks of pixels divided by 255, obtaining range is 0 ~1 floating number;
Each floating number is made into the power operation that power is gamma respectively, is obtained each in each described blocks of pixels The linear value of R, G, B color component of pixel.
Preferably, the average value for seeking each color component in each blocks of pixels respectively in linear space, Include:
When the linear value of each color component of each pixel is respectively R ', G ' and B ', each pixel point The average value of each color component is respectively as follows: R in blockavg=(R1 '+R2 '+R3 '+R4 ')/4, Gavg=(G1 '+G2 '+G3 '+ G4 ')/4 and Bavg=(B1 '+B2 '+B3 '+B4 ')/4, the R1 ', R2 ', R3 ' and R4 ' are respectively in each blocks of pixels The R color component linear value of each pixel, the G1 ', G2 ', G3 ' and G4 ' are respectively each picture in each blocks of pixels The G color component linear value of element, the B1 ', B2 ', B3 ' and B4 ' are respectively the B face of each pixel in each blocks of pixels Colouring component linear value.
Preferably, described that each average value is mapped in 0~255 range of corresponding color component, it respectively obtains R, G, B of each blocks of pixels correct color component, comprising:
Table linear_2_gamma is defined, has t_size+1 index entry in table linear_2_gamma, t_size is positive Integer, Xt_pos=Xavg/ (1/t_size), Xt_posCalculated result be rounded downwards, make Xt_posIn table linear_2_gamma An index entry it is corresponding, wherein X be R color component, G color component or B color component, XavgFor the blocks of pixels X The average value of color component;
Define linear_2_gamma [Xt_pos]=pow (Xt_pos/ t_size, 1/gamma) * 255, respectively by each institute The average value for stating each color component in blocks of pixels is mapped in 0~255 range of corresponding color component, obtains each institute State the mapping value of each color component in blocks of pixels;
The mapping value of each color component in each blocks of pixels is modified,Wherein, XreviseFor the amendment face of X Colouring component.
Preferably, described that each average value is mapped in 0~255 range of corresponding color component, it respectively obtains R, G, B of each blocks of pixels correct color component, comprising:
Each average value is made into the power operation that power is 1/gamma respectively, respectively obtains each described blocks of pixels The mapping value of middle R, G, B color component;
The mapping value of R, G, B color component in each described blocks of pixels is taken multiplied by 255, and by calculated result respectively Whole R, G, B the amendment color component for obtaining each blocks of pixels.
Preferably, the value of above-mentioned gamma is 2.2.
A kind of rgb format image turns the device of YUV420 format, comprising:
Cutting unit, for the blocks of pixels for being multiple 2*2 by rgb format image segmentation to be processed;
First computing unit, in the coefficient according to as defined in preset standard and the rgb format image to be processed Each pixel R, G, B color component, calculate the Y-component of each pixel;
Amending unit, for being respectively mapped to R, G, B color component of each pixel in each described blocks of pixels Linear space seeks the average value of each color component in each blocks of pixels in linear space respectively, and each institute It states average value to be mapped in 0~255 range of corresponding color component, respectively obtains R, G, B amendment of each blocks of pixels Color component;
Second computing unit, for the coefficient according to as defined in the preset standard and each blocks of pixels R, G, B corrects color component, calculates separately the U component and V component of each blocks of pixels, in conjunction with Y points of each pixel Amount, obtains the image of YUV420 format.
Preferably, when the rgb format image to be processed is RGB32 format, described device further include:
Conversion unit, for converting RGB24 format-pattern for RGB32 format-pattern to be processed.
Preferably, the amending unit includes mapping subelement;
The mapping subelement, for respectively by R, G, B color component of each pixel in each described blocks of pixels Divided by 255, the floating number that range is 0~1 is obtained;Each floating number is made into the power operation that power is gamma respectively, is obtained every The linear value of R, G, B color component of each pixel in one blocks of pixels.
Preferably, the amending unit includes computation subunit;
The computation subunit, for when each pixel each color component linear value be respectively R ', G ' and When B ', the average value of each color component is respectively as follows: R in each blocks of pixelsavg=(R1 '+R2 '+R3 '+R4 ')/4, Gavg=(G1 '+G2 '+G3 '+G4 ')/4 and Bavg=(B1 '+B2 '+B3 '+B4 ')/4, the R1 ', R2 ', R3 ' and R4 ' are respectively For the R color component linear value of each pixel in each blocks of pixels, the G1 ', G2 ', G3 ' and G4 ' are respectively each The G color component linear value of each pixel in the blocks of pixels, the B1 ', B2 ', B3 ' and B4 ' are respectively each picture The B color component linear value of each pixel in plain piecemeal.
Preferably, the amending unit includes the first inverse mapping subelement,
The first inverse mapping subelement has t_ in table linear_2_gamma for defining table linear_2_gamma Size+1 index entry, t_size are positive integer, Xt_pos=Xavg/ (1t_size), Xt_posCalculated result be rounded downwards, make Xt_posIt is corresponding with an index entry in table linear_2_gamma, wherein X is R color component, G color component or B color Component, XavgFor the average value of the blocks of pixels X color component;Define linear_2_gamma [Xt_pos]=pow (Xt_pos/ T_size, 1gamma) * 255, the average value of each color component in each blocks of pixels is mapped to corresponding face respectively In 0~255 range of colouring component, the mapping value of each color component in each blocks of pixels is obtained;To each picture The mapping value of each color component is modified in plain piecemeal,Wherein, XreviseFor the amendment face of X Colouring component.
Preferably, the amending unit includes the second inverse mapping subelement;
The second inverse mapping subelement, for each average value to be made the power operation that power is 1/gamma respectively, point The mapping value of R, G, B color component in each described blocks of pixels is not obtained;Respectively by R in each described blocks of pixels, G, the mapping value of B color component corrects face multiplied by 255, and by R, G, B that calculated result is rounded to obtain each blocks of pixels Colouring component.
Compared with the existing technology, beneficial effects of the present invention are as follows:
Rgb format image provided by the invention turns the method and device of YUV420 format, by rgb format image to be processed It is divided into the blocks of pixels of multiple 2*2;In the coefficient according to as defined in preset standard and the rgb format image to be processed Each pixel R, G, B color component, calculate the Y-component of each pixel;It respectively will be in each described blocks of pixels R, G, B color component of each pixel are mapped to linear space, seek respectively in linear space every in each blocks of pixels The average value of a color component, and each average value is mapped in 0~255 range of corresponding color component, respectively R, G, B to each blocks of pixels correct color component;It avoids in the prior art, due to not by each color component Value be transformed into linear space, but directly the color component of pixel each in blocks of pixels is added and is averaging or fixed selects Some pixel does sampled point, causes under VDI environment picture Key detail problem easy to be lost in CAD scene.So The U component and V component for calculating separately each blocks of pixels further according to R, G, B amendment color component afterwards, finally combine Y-component, obtain To the image of YUV420 format, the display effect of image is improved.
Detailed description of the invention
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this The embodiment of invention for those of ordinary skill in the art without creative efforts, can also basis The attached drawing of offer obtains other attached drawings.
Fig. 1 is the method flow diagram that a kind of rgb format image disclosed by the embodiments of the present invention turns YUV420 format;
Fig. 2 is the apparatus structure schematic diagram that a kind of rgb format image disclosed by the embodiments of the present invention turns YUV420 format.
Specific embodiment
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete Site preparation description, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.It is based on Embodiment in the present invention, it is obtained by those of ordinary skill in the art without making creative efforts every other Embodiment shall fall within the protection scope of the present invention.
Inventor it has been investigated that, the method that two kinds of rgb format images existing in the prior art turn YUV420 format, There is a problem of that picture Key detail is easy to be lost in CAD scene under VDI environment.
Wherein, a kind of prior art is the blocks of pixels for being multiple 2*2 by rgb format image segmentation to be processed, respectively Each color component of pixel each in each blocks of pixels is summed up into averaging, using average value as each pixel The value of each color component of piecemeal, this method do not meet the perception characteristics of human vision, and the color of image distortion after conversion is tight Weight.
Another prior art is the blocks of pixels for being multiple 2*2 by rgb format image segmentation to be processed, in each picture Down-sampling is carried out in each pixel in plain piecemeal and selects sampled point, using the value of each color component of sampled point as each Apparent visual difference is not present in value of a blocks of pixels per each and every one color component, this implementation method in the processing of natural image Not, be because the image of nature is mostly visually continuous, and when showing CAD image under VDI environment, This method is not appropriate for, and converted images cross-color is serious.
In view of this, present embodiment discloses a kind of methods that rgb format image turns YUV420 format, referring to Fig. 1, institute State method the following steps are included:
S101: the blocks of pixels for being multiple 2*2 by rgb format image segmentation to be processed;
Specifically, rgb format image to be processed can be RGB32 format or RGB24 format.
RGB24 uses R, G, B three primary colors, i.e. Red Green Blue, each color component is indicated with 8, three components Be added together is 24.RGB32 also adds 8 positions alpha, RGB32 other than 24 three primary colors that RGB24 includes It can be converted with RGB equivalence.
It should be noted that when the rgb format image to be processed is RGB32 format, before S101 further include:
RGB24 format-pattern is converted by RGB32 format-pattern to be processed.
It is understood that including 4 pixels in the blocks of pixels of each 2*2.
S102: the coefficient according to as defined in preset standard and each pixel in the rgb format image to be processed R, G, B color component calculates the Y-component of each pixel;
It should be noted that the preset standard can be ITU-R Recommendation BT.601 and ITU-R The standards such as Recommendation BT.709, preset standard respectively provide Y, U, V component coefficient, each pixel include R, G, tri- color components of B, according to ITU-R Recommendation BT.601 and ITU-R Recommendation BT.709 Etc. coefficient and tri- color components of R, G, B of each pixel in the rgb format image to be processed as defined in standards, The Y-component for calculating each pixel, so not doing multiprocessing to Y-component, directly takes since Y-component is not related to down-sampling Value.
S103: being mapped to linear space for R, G, B color component of each pixel in each described blocks of pixels respectively, The average value of each color component in each blocks of pixels is sought respectively in linear space, and each average value is reflected It is mapped in 0~255 range of corresponding color component, respectively obtains R, G, B amendment color component of each blocks of pixels;
Specifically, described be mapped to line for R, G, B color component of each pixel in each described blocks of pixels respectively Property space, a kind of preferred embodiment are as follows:
Respectively by R, G, B color component of each pixel in each described blocks of pixels divided by 255, obtaining range is 0 ~1 floating number;
Each floating number is made into the power operation that power is gamma respectively, is obtained each in each described blocks of pixels The linear value of R, G, B color component of pixel.
It should be noted that R, G of each pixel, B component respectively correspond some value in 0~255 grade of brightness; The value of gamma can be adjusted according to actual needs, it is preferred that the value range of gamma is (0,5), by many experiments Verifying, 2.2 be the best value of gamma, and other values in (0,5) range can also be selected according to actual scene.
It should also be noted that, processing when being 0 for floating number can according to reality in the conversion process of picture format To be adjusted according to the actual situation, in a kind of possible situation, floating number 0 is added into a smaller numerical value, this The value range of numerical value is (0,1), 0.01 is generally taken, then floating number 0.01 is made the power operation that power is gamma, after image conversion Display effect may more preferably.User can decide whether floating number 0 is smaller plus one according to actual test Numerical value handled again.
Specifically, each pixel includes R color component, G color component and B color component, it is described in linear space The average value for seeking each color component in each blocks of pixels respectively can be there are many method, wherein a kind of method are as follows:
When the linear value of each color component of each pixel is respectively R ', G ' and B ', each pixel point The average value of each color component is respectively as follows: R in blockavg=(R1 '+R2 '+R3 '+R4 ')/4, Gavg=(G1 '+G2 '+G3 '+ G4 ')/4 and Bavg=(B1 '+B2 '+B3 '+B4 ')/4, the R1 ', R2 ', R3 ' and R4 ' are respectively in each blocks of pixels The R color component linear value of each pixel, the G1 ', G2 ', G3 ' and G4 ' are respectively each picture in each blocks of pixels The G color component linear value of element, the B1 ', B2 ', B3 ' and B4 ' are respectively the B face of each pixel in each blocks of pixels Colouring component linear value.
Another method are as follows:
When the linear value of each color component of each pixel is respectively R ', G ' and B ', each pixel point The average value of each color component is respectively as follows: in block
WithThe R1 ', R2 ', R3 ' It is respectively the R color component linear value of each pixel in each blocks of pixels, the G1 ', G2 ', G3 ' and G4 ' points with R4 ' Not Wei in each blocks of pixels each pixel G color component linear value, the B1 ', B2 ', B3 ' and B4 ' are respectively every The B color component linear value of each pixel in a blocks of pixels.
Specifically, described be mapped to each average value in 0~255 range of corresponding color component, respectively obtain R, G, B of each blocks of pixels correct color component, can be there are many method, and preferably a kind of the specific of method executes step It is rapid as follows:
Table linear_2_gamma is defined, has t_size+1 index entry in table linear_2_gamma, t_size is positive Integer, Xt_pos=Xavg/ (1/t_size), Xt_posCalculated result be rounded downwards, make Xt_posIn table linear_2_gamma An index entry it is corresponding, wherein X be R color component, G color component or B color component, XavgFor the blocks of pixels X The average value of color component;
Define linear_2_gamma [Xt_pos]=pow (Xt_pos/ t_size, 1/gamma) * 255, respectively by each institute The average value for stating each color component in blocks of pixels is mapped in 0~255 range of corresponding color component, obtains each institute State the mapping value of each color component in blocks of pixels;
The mapping value of each color component in each blocks of pixels is modified,Wherein, XreviseFor the amendment face of X Colouring component.
It is illustrated so that t_size is 5 as an example, there is 6 index entries in table linear_2_gamma, R, G, B color component Average value corresponds in table linear_2_gamma in [0,1], and the average value of R, G, B color component respectively corresponds 0,0.2, 0.4,0.6,0.8,1.0, then respective value of the average value of R, G, B color component in table linear_2_gamma is made into power respectively The mapping of R, G, B color component in each described blocks of pixels is respectively obtained multiplied by 255 for the power operation of 1/gamma Value, it may be assumed that
Linear_2_gamma [0]=pow (0,1/gamma) * 255;
Linear_2_gamma [1]=pow (0.2,1/gamma) * 255;
Linear_2_gamma [2]=pow (0.4,1/gamma) * 255;
Linear_2_gamma [3]=pow (0.6,1/gamma) * 255;
Linear_2_gamma [4]=pow (0.8,1/gamma) * 255;
Linear_2_gamma [5]=pow (1.0,1/gamma) * 255.
It should be noted that R, G of each pixel, B component respectively correspond some value in 0~255 grade of brightness; The value of gamma can be adjusted according to actual needs, it is preferred that the value range of gamma is (0,5), by many experiments Verifying, 2.2 be the best value of gamma, and other values in (0,5) range can also be selected according to actual scene.
Finally, being repaired using mapping value of the linear difference method R, G, B color component in each described blocks of pixels Just.This modification method accuracy rate is high, keeps the display effect of image more preferable.
Another " is mapped to each average value in 0~255 range of corresponding color component, respectively obtains each A kind of optional specific implementation procedure of R, G, B amendment color component of a blocks of pixels " is as follows:
Each average value is made into the power operation that power is 1/gamma respectively, respectively obtains each described blocks of pixels The mapping value of middle R, G, B color component;
The mapping value of R, G, B color component in each described blocks of pixels is taken multiplied by 255, and by calculated result respectively Whole R, G, B the amendment color component for obtaining each blocks of pixels.
It should be noted that R, G of each pixel, B component respectively correspond some value in 0~255 grade of brightness; The value of gamma can be adjusted according to actual needs, it is preferred that the value range of gamma is (0,5), by many experiments Verifying, 2.2 be the best value of gamma, and other values in (0,5) range can also be selected according to actual scene.
It should also be noted that, the rounding mode to round up can be used, rounding up or being rounded downwards is ok.Example Such as: calculated result 1.6, calculated result can be rounded up is 2, or being rounded downwards is 1.
S104: according to coefficient as defined in the preset standard and R, G, B of each blocks of pixels amendment color point Amount, the U component and V component for calculating separately each blocks of pixels obtain YUV420 in conjunction with the Y-component of each pixel The image of format.
It should be noted that the preset standard in step S104 may be ITU-R Recommendation BT.601 With the standards such as ITU-R Recommendation BT.709.
The method that rgb format image provided in this embodiment turns YUV420 format, by rgb format image segmentation to be processed For the blocks of pixels of multiple 2*2;It is each in the coefficient according to as defined in preset standard and the rgb format image to be processed R, G, B color component of a pixel calculate the Y-component of each pixel;It respectively will be each in each described blocks of pixels R, G, B color component of pixel are mapped to linear space, seek each face in each blocks of pixels respectively in linear space The average value of colouring component, and each average value is mapped in 0~255 range of corresponding color component, it respectively obtains each R, G, B of a blocks of pixels correct color component;It avoids in the prior art, due to not by the value of each color component It is transformed into linear space, but directly the color component of pixel each in blocks of pixels is added to be averaging or fix and selects some Pixel does sampled point, causes under VDI environment picture Key detail problem easy to be lost in CAD scene.Then again The U component and V component that color component calculates separately each blocks of pixels are corrected according to R, G, B, Y-component is finally combined, obtains The image of YUV420 format improves the display effect of image.
Referring to Fig. 2, disclosed rgb format image turns the method for YUV420 format, the present embodiment based on the above embodiment A kind of corresponding device for disclosing rgb format image and turning YUV420 format, comprising:
It should be noted that when the rgb format image to be processed is RGB32 format, described device further include:
Conversion unit, for converting RGB24 format-pattern for RGB32 format-pattern to be processed.
If rgb format image to be processed is RGB24 format, directly carry out with the operation of lower unit:
Cutting unit 101, for the blocks of pixels for being multiple 2*2 by rgb format image segmentation to be processed;
First computing unit 102 is used for the coefficient according to as defined in preset standard and the rgb format figure to be processed R, G, B color component of each pixel as in calculate the Y-component of each pixel;
It should be noted that the preset standard can be ITU-R Recommendation BT.601 and ITU-R The standards such as Recommendation BT.709, preset standard respectively provide Y, U, V component coefficient, each pixel include R, G, tri- color components of B, according to ITU-R Recommendation BT.601 and ITU-R Recommendation BT.709 Etc. coefficient and tri- color components of R, G, B of each pixel in the rgb format image to be processed as defined in standards, The Y-component for calculating each pixel, so not doing multiprocessing to Y-component, directly takes since Y-component is not related to down-sampling Value.
Amending unit 103, for respectively mapping R, G, B color component of each pixel in each described blocks of pixels To linear space, the average value of each color component in each blocks of pixels is sought respectively in linear space, and each The average value is mapped in 0~255 range of corresponding color component, and R, G, the B for respectively obtaining each blocks of pixels are repaired Positive color component;
Second computing unit 104, for the coefficient according to as defined in the preset standard and each blocks of pixels R, G, B correct color component, the U component and V component of each blocks of pixels are calculated separately, in conjunction with the Y of each pixel Component obtains the image of YUV420 format.
Specifically, the amending unit 103 includes mapping subelement, computation subunit and inverse mapping subelement, wherein meter There are two types of implementations respectively for operator unit and inverse mapping subelement.
The mapping subelement, for respectively by R, G, B color component of each pixel in each described blocks of pixels Divided by 255, the floating number that range is 0~1 is obtained;Each floating number is made into the power operation that power is gamma respectively, is obtained every The linear value of R, G, B color component of each pixel in one blocks of pixels.
The computation subunit, for when each pixel each color component linear value be respectively R ', G ' and When B ', the average value of each color component is respectively as follows: R in each blocks of pixelsavg=(R1 '+R2 '+R3 '+R4 ')/4, Gavg=(G1 '+G2 '+G3 '+G4 ')/4 and Bavg=(B1 '+B2 '+B3 '+B4 ')/4, the R1 ', R2 ', R3 ' and R4 ' are respectively The R color component linear value of each pixel in each blocks of pixels, the G1 ', G2 ', G3 ' and G4 ' are respectively each institute The G color component linear value of each pixel in blocks of pixels is stated, the B1 ', B2 ', B3 ' and B4 ' are respectively each pixel The B color component linear value of each pixel in piecemeal.
Another implementation of computation subunit are as follows:
When the linear value of each color component of each pixel is respectively R ', G ' and B ', each pixel point The average value of each color component is respectively as follows: in block
WithThe R1 ', R2 ', R3 ' It is respectively the R color component linear value of each pixel in each blocks of pixels, the G1 ', G2 ', G3 ' and G4 ' points with R4 ' Not Wei in each blocks of pixels each pixel G color component linear value, the B1 ', B2 ', B3 ' and B4 ' are respectively every The B color component linear value of each pixel in a blocks of pixels.
Two kinds of implementations of inverse mapping subelement use respectively the first inverse mapping subelement and the second inverse mapping subelement into Row explanation.
First inverse mapping subelement has t_size+ in table linear_2_gamma for defining table linear_2_gamma 1 index entry, t_size are positive integer, Xt_pos=Xavg/ (1/t_size), Xt_posCalculated result be rounded downwards, make Xt_pos It is corresponding with an index entry in table linear_2_gamma, wherein X is R color component, G color component or B color point Amount, XavgFor the average value of the blocks of pixels X color component;Define linear_2_gamma [Xt_pos]=pow (Xt_pos/t_ Size, 1/gamma) * 255, the average value of each color component in each blocks of pixels is mapped to corresponding face respectively In 0~255 range of colouring component, the mapping value of each color component in each blocks of pixels is obtained;To each picture The mapping value of each color component is modified in plain piecemeal,Wherein, XreviseFor the amendment face of X Colouring component.
Second inverse mapping subelement, for each average value to be made the power operation that power is 1/gamma respectively, respectively The mapping value of R, G, B color component into blocks of pixels described in each;Respectively by R, G, B face in each described blocks of pixels Calculated result is rounded to obtain R, G, B amendment color point of each blocks of pixels by the mapping value of colouring component multiplied by 255 Amount.
It should be noted that R, G of each pixel, B component respectively correspond some value in 0~255 grade of brightness; The value of gamma can be adjusted according to actual needs, it is preferred that the value range of gamma is (0,5), by many experiments Verifying, 2.2 be the best value of gamma, and other values in (0,5) range can also be selected according to actual scene.
Rgb format image disclosed in the present embodiment turns the device of YUV420 format, and amending unit 103 is by each blocks of pixels In each pixel each color component, be mapped to linear space, then be averaging, and by average value inverse mapping to corresponding color In 0~255 range of component, each amendment color component of each blocks of pixels is obtained, CAD field is avoided The problem of picture Key detail is lost in scape, improves display effect.
The foregoing description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, as defined herein General Principle can be realized in other embodiments without departing from the spirit or scope of the present invention.Therefore, of the invention It is not intended to be limited to the embodiments shown herein, and is to fit to and the principles and novel features disclosed herein phase one The widest scope of cause.

Claims (13)

1. a kind of method that rgb format image turns YUV420 format characterized by comprising
The blocks of pixels for being multiple 2*2 by rgb format image segmentation to be processed;
R, G, B color of the coefficient according to as defined in preset standard and each pixel in the rgb format image to be processed Component calculates the Y-component of each pixel;
R, G, B color component of each pixel in each described blocks of pixels are mapped to linear space respectively, linear empty Between seek the average value of each color component in each blocks of pixels respectively, and each average value is mapped to accordingly In 0~255 range of color component, R, G, B amendment color component of each blocks of pixels are respectively obtained;
Color component is corrected according to coefficient as defined in the preset standard and R, G, B of each blocks of pixels, is counted respectively The U component and V component for calculating each blocks of pixels obtain the figure of YUV420 format in conjunction with the Y-component of each pixel Picture.
2. the method according to claim 1, wherein when the rgb format image to be processed is RGB32 format When, in the blocks of pixels for being multiple 2*2 by rgb format image segmentation to be processed, before further include:
RGB24 format-pattern is converted by RGB32 format-pattern to be processed.
3. the method according to claim 1, wherein described respectively by each picture in each described blocks of pixels R, G, B color component of element are mapped to linear space, comprising:
Respectively by R, G, B color component of each pixel in each described blocks of pixels divided by 255, obtaining range is 0~1 Floating number;
Each floating number is made into the power operation that power is gamma respectively, obtains each pixel in each described blocks of pixels R, G, B color component linear value.
4. the method according to claim 1, wherein described seek each pixel point in linear space respectively The average value of each color component in block, comprising:
When the linear value of each color component of each pixel is respectively R ', G ' and B ', in each blocks of pixels The average value of each color component is respectively as follows: Ravg=(R1 '+R2 '+R3 '+R4 ')/4, Gavg=(G1 '+G2 '+G3 '+G4 ')/4 And Bavg=(B1 '+B2 '+B3 '+B4 ')/4, the R1 ', R2 ', R3 ' and R4 ' are respectively each picture in each blocks of pixels The R color component linear value of element, the G1 ', G2 ', G3 ' and G4 ' are respectively the G face of each pixel in each blocks of pixels Colouring component linear value, the B1 ', B2 ', B3 ' and B4 ' are respectively the B color component of each pixel in each blocks of pixels Linear value.
5. the method according to claim 1, wherein described be mapped to corresponding color point each average value In 0~255 range of amount, R, G, B amendment color component of each blocks of pixels are respectively obtained, comprising:
Table linear_2_gamma is defined, has t_size+1 index entry in table linear_2_gamma, t_size is positive integer, Xt_pos=Xavg/ (1/t_size), Xt_posCalculated result be rounded downwards, make Xt_posWith one in table linear_2_gamma Index entry is corresponding, wherein X is R color component, G color component or B color component, XavgFor the blocks of pixels X color point The average value of amount;
Define linear_2_gamma [Xt_pos]=pow (Xt_pos/ t_size, 1/gamma) * 255, respectively by each pixel The average value of each color component is mapped in 0~255 range of corresponding color component in piecemeal, obtains each pixel The mapping value of each color component in piecemeal;
The mapping value of each color component in each blocks of pixels is modified,Wherein, XreviseFor the amendment face of X Colouring component.
6. the method according to claim 1, wherein described be mapped to corresponding color point each average value In 0~255 range of amount, R, G, B amendment color component of each blocks of pixels are respectively obtained, comprising:
By each average value make respectively power be 1/gamma power operation, respectively obtain R in each described blocks of pixels, G, the mapping value of B color component;
The mapping value of R, G, B color component in each described blocks of pixels is rounded multiplied by 255, and by calculated result respectively R, G, B to each blocks of pixels correct color component.
7. according to the described in any item methods of claim 3,5,6, which is characterized in that the value range of the gamma be (0, 5)。
8. the device that a kind of rgb format image turns YUV420 format characterized by comprising
Cutting unit, for the blocks of pixels for being multiple 2*2 by rgb format image segmentation to be processed;
First computing unit, for each in the coefficient according to as defined in preset standard and the rgb format image to be processed R, G, B color component of a pixel calculate the Y-component of each pixel;
Amending unit, for being respectively mapped to R, G, B color component of each pixel in each described blocks of pixels linearly The average value of each color component in each blocks of pixels is sought in linear space in space respectively, and each described flat Mean value is mapped in 0~255 range of corresponding color component, respectively obtains R, G, B amendment color of each blocks of pixels Component;
Second computing unit, R, G, B for the coefficient according to as defined in the preset standard and each blocks of pixels are repaired Positive color component, the U component and V component for calculating separately each blocks of pixels are obtained in conjunction with the Y-component of each pixel To the image of YUV420 format.
9. device according to claim 8, which is characterized in that when the rgb format image to be processed is RGB32 format When, described device further include:
Conversion unit, for converting RGB24 format-pattern for RGB32 format-pattern to be processed.
10. device according to claim 8, which is characterized in that the amending unit includes mapping subelement;
The mapping subelement, for respectively by R, G, B color component of each pixel in each described blocks of pixels divided by 255, obtain the floating number that range is 0~1;Each floating number is made into the power operation that power is gamma respectively, obtains each The linear value of R, G, B color component of each pixel in the blocks of pixels.
11. device according to claim 8, which is characterized in that the amending unit includes computation subunit;
The computation subunit, for when the linear value of each color component of each pixel is respectively R ', G ' and B ', The average value of each color component is respectively as follows: R in each blocks of pixelsavg=(R1 '+R2 '+R3 '+R4 ')/4, Gavg= (G1 '+G2 '+G3 '+G4 ')/4 and Bavg=(B1 '+B2 '+B3 '+B4 ')/4, the R1 ', R2 ', R3 ' and R4 ' are respectively each The R color component linear value of each pixel in the blocks of pixels, the G1 ', G2 ', G3 ' and G4 ' are respectively each picture The G color component linear value of each pixel in plain piecemeal, the B1 ', B2 ', B3 ' and B4 ' are respectively each blocks of pixels In each pixel B color component linear value.
12. device according to claim 8, which is characterized in that the amending unit includes the first inverse mapping subelement,
The first inverse mapping subelement has t_size+ in table linear_2_gamma for defining table linear_2_gamma 1 index entry, t_size are positive integer, Xt_pos=Xavg/ (1/t_size), Xt_posCalculated result be rounded downwards, make Xt_pos It is corresponding with an index entry in table linear_2_gamma, wherein X is R color component, G color component or B color point Amount, XavgFor the average value of the blocks of pixels X color component;Define linear_2_gamma [Xt_pos]=pow (Xt_pos/t_ Size, 1/gamma) * 255, the average value of each color component in each blocks of pixels is mapped to corresponding face respectively In 0~255 range of colouring component, the mapping value of each color component in each blocks of pixels is obtained;
The mapping value of each color component in each blocks of pixels is modified,Wherein, XreviseFor the amendment face of X Colouring component.
13. device according to claim 8, which is characterized in that the amending unit includes the second inverse mapping subelement;
The second inverse mapping subelement, for each average value to be made the power operation that power is 1/gamma respectively, respectively The mapping value of R, G, B color component into blocks of pixels described in each;Respectively by R, G, B face in each described blocks of pixels Calculated result is rounded to obtain R, G, B amendment color point of each blocks of pixels by the mapping value of colouring component multiplied by 255 Amount.
CN201710174818.9A 2017-03-22 2017-03-22 A kind of rgb format image turns the method and device of YUV420 format Active CN106973277B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710174818.9A CN106973277B (en) 2017-03-22 2017-03-22 A kind of rgb format image turns the method and device of YUV420 format

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710174818.9A CN106973277B (en) 2017-03-22 2017-03-22 A kind of rgb format image turns the method and device of YUV420 format

Publications (2)

Publication Number Publication Date
CN106973277A CN106973277A (en) 2017-07-21
CN106973277B true CN106973277B (en) 2019-02-05

Family

ID=59330030

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710174818.9A Active CN106973277B (en) 2017-03-22 2017-03-22 A kind of rgb format image turns the method and device of YUV420 format

Country Status (1)

Country Link
CN (1) CN106973277B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110786007A (en) * 2018-10-31 2020-02-11 深圳市大疆创新科技有限公司 Method and apparatus for processing image data
CN112509072A (en) * 2020-11-24 2021-03-16 北京三快在线科技有限公司 Image format detection and conversion method and device

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1571472A (en) * 2003-07-25 2005-01-26 金宝电子工业股份有限公司 Digital visual signal processing circuit with high dynamic range and circuit element therein
US7002627B1 (en) * 2002-06-19 2006-02-21 Neomagic Corp. Single-step conversion from RGB Bayer pattern to YUV 4:2:0 format
CN101621703A (en) * 2009-08-06 2010-01-06 北京中企开源信息技术有限公司 Method for colour space conversion of image sequence
CN101719985A (en) * 2009-11-17 2010-06-02 北京中星微电子有限公司 Method and device for collecting and processing images
CN102118624A (en) * 2011-03-08 2011-07-06 天脉聚源(北京)传媒科技有限公司 Method for converting an image from an RGB color space to a YUV color space
CN102281439A (en) * 2011-06-16 2011-12-14 杭州米加科技有限公司 Streaming media video image preprocessing method
CN102542548A (en) * 2011-12-30 2012-07-04 深圳市万兴软件有限公司 Method and device for correcting color between images
CN102752604A (en) * 2012-06-18 2012-10-24 深圳创维-Rgb电子有限公司 Image display method and intelligent device
CN104168483A (en) * 2014-07-08 2014-11-26 大连民族学院 Video compression method and system
US8947449B1 (en) * 2012-02-21 2015-02-03 Google Inc. Color space conversion between semi-planar YUV and planar YUV formats
CN104601971A (en) * 2014-12-31 2015-05-06 小米科技有限责任公司 Color adjustment method and device

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7002627B1 (en) * 2002-06-19 2006-02-21 Neomagic Corp. Single-step conversion from RGB Bayer pattern to YUV 4:2:0 format
CN1571472A (en) * 2003-07-25 2005-01-26 金宝电子工业股份有限公司 Digital visual signal processing circuit with high dynamic range and circuit element therein
CN101621703A (en) * 2009-08-06 2010-01-06 北京中企开源信息技术有限公司 Method for colour space conversion of image sequence
CN101719985A (en) * 2009-11-17 2010-06-02 北京中星微电子有限公司 Method and device for collecting and processing images
CN102118624A (en) * 2011-03-08 2011-07-06 天脉聚源(北京)传媒科技有限公司 Method for converting an image from an RGB color space to a YUV color space
CN102281439A (en) * 2011-06-16 2011-12-14 杭州米加科技有限公司 Streaming media video image preprocessing method
CN102542548A (en) * 2011-12-30 2012-07-04 深圳市万兴软件有限公司 Method and device for correcting color between images
US8947449B1 (en) * 2012-02-21 2015-02-03 Google Inc. Color space conversion between semi-planar YUV and planar YUV formats
CN102752604A (en) * 2012-06-18 2012-10-24 深圳创维-Rgb电子有限公司 Image display method and intelligent device
CN104168483A (en) * 2014-07-08 2014-11-26 大连民族学院 Video compression method and system
CN104601971A (en) * 2014-12-31 2015-05-06 小米科技有限责任公司 Color adjustment method and device

Also Published As

Publication number Publication date
CN106973277A (en) 2017-07-21

Similar Documents

Publication Publication Date Title
JP6678209B2 (en) Gradient adjustment for texture mapping to non-orthonormal grid
EP2705501B1 (en) Texturing in graphics hardware
CN106899840B (en) Panoramic picture mapping method
CN106411877A (en) Method and system for implementing gift giving in video live broadcasting process on basis of AR (Augmented Reality) technology
CN111199518B (en) Image presentation method, device and equipment of VR equipment and computer storage medium
US20060152579A1 (en) Stereoscopic imaging system
US9042678B2 (en) Method and apparatus for reducing size of image data
US9947258B2 (en) Image processing method and image processing apparatus
KR100935173B1 (en) Perspective transformation of two-dimensional images
US20190385343A1 (en) Image processing method, electronic device and apparatus having storage function
WO1999067748A2 (en) An improved method and apparatus for per pixel mip mapping and trilinear filtering
CN106973277B (en) A kind of rgb format image turns the method and device of YUV420 format
CN108022223A (en) A kind of tone mapping method based on the processing fusion of logarithmic mapping function piecemeal
CN101662695B (en) Method and device for acquiring virtual viewport
CN116112761B (en) Method and device for generating virtual image video, electronic equipment and storage medium
US8212835B1 (en) Systems and methods for smooth transitions to bi-cubic magnification
CN116453470A (en) Image display method, device, electronic equipment and computer readable storage medium
CN108510927B (en) Method and device for enhancing image contrast in curved surface display screen
JP2591189B2 (en) Color image processing method and apparatus
CN108762855A (en) A kind of picture processing method and device
JP4366093B2 (en) Look-up table creation method, computer program, and imaging apparatus
WO2022103117A1 (en) Perceptual color enhancement based on properties of responses of human vision system to color stimulus
CN106028135A (en) Method and device for adjusting description of three-dimensional scene in virtual reality
CN111354064B (en) Texture image generation method and device
JP2898569B2 (en) Video accelerator board for computer game development

Legal Events

Date Code Title Description
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant