English 中文(简体)
失去无报酬的微额信贷
原标题:Lossless RGB to Y CbCr transformation

我试图无情地压缩形象,为了利用常态,我想将格勃的形象从格勃转变到Y CbCr。 (关于我所说的话的确切细节在这里并不重要;罗姆妇女联盟的数据由三根 by组成,我有三家 by来储存结果)。)

转换过程本身相当简单,但有一个问题:虽然转变在数学上是不可逆的,但实际上将出现四舍五入的错误。 当然,这些错误是小的,几乎是无法理解的,但它并不意味着这一进程不会再失去意义。

我的问题是:是否发生了转变,将3个8个轨道群(代表红色、绿色和蓝色部分)转换成另外3个8个轨道群(代表一个类似于Y CbCr的彩色空间,其中两个部分只稍微改变位置,或至少低于在RGB彩色空间),并且可以在无信息的情况下加以变?

最佳回答

<>12>

这里,我称之为“YCoCg24”,将3个8个轨道群(红色、绿色和蓝色成分)转换成另外3个8个轨道(签名)分类(代表与YCbCr相似的彩色空间),是双目标(因此可以在不丧失信息的情况下进行):

 G          R          B     Y          Cg         Co
 |          |          |     |          |          |
 |          |->-(-1)->(+)   (+)<-(-/2)<-|          |
 |          |          |     |          |          |
 |         (+)<-(/2)-<-|     |->-(+1)->(+)         |
 |          |          |     |          |          |
 |->-(-1)->(+)         |     |         (+)<-(-/2)<-|
 |          |          |     |          |          |
(+)<-(/2)-<-|          |     |          |->-(+1)->(+)
 |          |          |     |          |          |
 Y          Cg         Co    G          R          B

forward transformation       reverse transformation

或载于pseudocode:

function forward_lift( x, y ):
    signed int8 diff = ( y - x ) mod 0x100
    average = ( x + ( diff >> 1 ) ) mod 0x100
    return ( average, diff )

function reverse_lift( average, signed int8 diff ):
    x = ( average - ( diff >> 1 ) ) mod 0x100
    y = ( x + diff ) mod 0x100
    return ( x, y )

function RGB_to_YCoCg24( red, green, blue ):
    (temp, Co) = forward_lift( red, blue )
    (Y, Cg)    = forward_lift( green, temp )
    return( Y, Cg, Co)

function YCoCg24_to_RGB( Y, Cg, Co ):
    (green, temp) = reverse_lift( Y, Cg )
    (red, blue)   = reverse_lift( temp, Co)
    return( red, green, blue )

例如:

color        R G B     Y CoCg24
white      0xFFFFFF  0xFF0000
light grey 0xEFEFEF  0xEF0000
dark grey  0x111111  0x110000
black      0x000000  0x000000

red        0xFF0000  0xFF01FF
lime       0x00FF00  0xFF0001
blue       0x0000FF  0xFFFFFF

G,R-G,B-G色空间

另一种图形转变,将3个8个轨道分类账转换成另外3个8个轨道分类账。

function RGB_to_GCbCr( red, green, blue ):
    Cb = (blue - green) mod 0x100
    Cr = (red  - green) mod 0x100
    return( green, Cb, Cr)

function GCbCr_to_RGB( Y, Cg, Co ):
    blue = (Cb + green) mod 0x100
    red  = (Cr + green) mod 0x100
    return( red, green, blue )

例如:

color        R G B     G CbCr
white      0xFFFFFF  0xFF0000
light grey 0xEFEFEF  0xEF0000
dark grey  0x111111  0x110000
black      0x000000  0x000000

There seem to be quite a few lossless color space transforms. Several lossless color space transforms are mentioned in Henrique S. Malvar, et al. "Lifting-based reversible color transformations for image compression"; there s the lossless colorspace transformation in JPEG XR; the original reversible color transform (ORCT) used in several "lossless JPEG" proposals; G, R-G, B-G color space; etc. Malvar et al seem pretty excited about the 26-bit YCoCg-R representation of a 24-bit RGB pixel.

然而,几乎全部需要24个以上的轨道来储存变形的粉色。

lifting Techno I use in YCoCg24 is similar to the one in Malvar et al and to the losslessnutspace transformation in JPEG XR.

由于添加是可逆的(和添加模块2 0x100是双目标), 任何从(a,b)改为(x,y),可在以下网站制作:

 a        b
 |        |
 |->-F->-(+)
 |        |
(+)-<-G-<-|
 |        |
 x        y

在(+)表示增加8倍(Modulo 0x100)的情况下,a b x y为全部8比值,F和G表示任何任意职能。

<>详细程度>

Why do you only have 3 bytes to store the result in? That sounds like a counter-productive premature optimization. If your goal is to losslessly compress an image into as small a compressed file as possible in a reasonable amount of time, then the size of the intermediate stages is irrelevant. It may even be counter-productive -- a "larger" intermediate representation (such as Reversible Colour Transform or the 26-bit YCoCg-R) may result in smaller final compressed file size than a "smaller" intermediate representation (such as RGB or YCoCg24).

EDIT: Oopsies. Either one of "(x) mod 0x100" or "(x) & 0xff" give exactly the same results -- the results I wanted. But somehow I jumbled them together to produce something that wouldn t work.

问题回答




相关问题
Convert RGBA color to RGB

How to convert a RGBA color tuple, example (96, 96, 96, 202), to corresponding RGB color tuple? Edit: What I want is to get a RGB value which is most similar to the RGBA tuple visually on white ...

Mixing two RGB color vectors to get resultant

I am trying to mix two source RGB vectors to create a third "resultant vector" that is an intuitive mix of the first two. Ideally, I would be able to emulate "real paint mixing characteristics", but ...

Color Detection using YCrCb color space?

This code I have found attempt to track red color in RGB color space, // red color detection, turn the detected one into white if (((red > (0.85 * (green + blue))) && (red > 105)) ...

Is QImage able to open and render pure 16-bit images?

I think the headline already explains what I want to know. Is there a possible way to open and save images with 16-bit with Qt? And I don t mean the 3*8=24bit or 4*8=32bit, what is quite the same as a ...

Hex colors: Numeric representation for "transparent"?

I am building a web CMS in which the user can choose colours for certain site elements. I would like to convert all colour values to hex to avoid any further formatting hassle ("rgb(x,y,z)" or named ...

热门标签