Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > sci.image.processing > #4139 > unrolled thread

Lossless rgb<->yuv discuss

Started byYang Luo <youngluoyang@gmail.com>
First post2016-07-17 16:25 -0700
Last post2016-07-18 08:20 -0700
Articles 3 — 3 participants

Back to article view | Back to sci.image.processing


Contents

  Lossless rgb<->yuv discuss Yang Luo <youngluoyang@gmail.com> - 2016-07-17 16:25 -0700
    Re: Lossless rgb<->yuv discuss Thomas Richter <thor@math.tu-berlin.de> - 2016-07-18 15:08 +0200
      Re: Lossless rgb<->yuv discuss Sand Glass <youngluoyang@gmail.com> - 2016-07-18 08:20 -0700

#4139 — Lossless rgb<->yuv discuss

FromYang Luo <youngluoyang@gmail.com>
Date2016-07-17 16:25 -0700
SubjectLossless rgb<->yuv discuss
Message-ID<303fec14-c8b3-40a7-913a-a274cc729ede@googlegroups.com>
Is there a lossless rgb<->yuv formula, no clip?
something like this: (not all OK)
C = 256 or 32 or 16
tmp = ((r-b)/2+b)
v = g - tmp + C
u = r - b + C
y = (g+tmp)/2; 

[toc] | [next] | [standalone]


#4141

FromThomas Richter <thor@math.tu-berlin.de>
Date2016-07-18 15:08 +0200
Message-ID<nmikcb$143$1@news2.informatik.uni-stuttgart.de>
In reply to#4139
On 18.07.2016 01:25, Yang Luo wrote:
> Is there a lossless rgb<->yuv formula, no clip?

Not "yuv" directly, but "ycgco", which is "close enough" to yuv for many
purposes. It doesn't clip, but it (necessarily) extends the range of the
chroma signal by one bit. Alternatively, you can also use RCT from JPEG
2000.

If you look for a continuous (i.e. no wrap-arounds, no jumps) lossless
conversion from RGB to some other color space *without* range extension,
then I afraid the identity transformation and trivial variations thereof
(i.e. reflections, and permutations of the axes) are the only option.


This is the forwards transform:

 LONG rp = *r;
 LONG gp = *g;
 LONG bp = *b;
 LONG v  = bp - rp;
 LONG t  = rp - gp + (v >> 1);
 LONG y  = gp + (t >> 1);
 LONG u  = -t;

And this is the backwards transform:

u         = -u;            // this was called t above
y        -= u >> 1;        // restore g. yp is now == g
u        += y - (v >> 1); // this restores r. up is now == r
v        += u;             // this restores b
r         = u
g         = y
b         = v

HTHH,
	Thomas

[toc] | [prev] | [next] | [standalone]


#4142

FromSand Glass <youngluoyang@gmail.com>
Date2016-07-18 08:20 -0700
Message-ID<f958e193-b4ae-40cf-aa85-96fd24f6e3b7@googlegroups.com>
In reply to#4141
在 2016年7月18日星期一 UTC+8下午9:08:29,Thomas Richter写道:
> On 18.07.2016 01:25, Yang Luo wrote:
> > Is there a lossless rgb<->yuv formula, no clip?
> 
> Not "yuv" directly, but "ycgco", which is "close enough" to yuv for many
> purposes. It doesn't clip, but it (necessarily) extends the range of the
> chroma signal by one bit. Alternatively, you can also use RCT from JPEG
> 2000.
> 
> If you look for a continuous (i.e. no wrap-arounds, no jumps) lossless
> conversion from RGB to some other color space *without* range extension,
> then I afraid the identity transformation and trivial variations thereof
> (i.e. reflections, and permutations of the axes) are the only option.
> 
> 
> This is the forwards transform:
> 
>  LONG rp = *r;
>  LONG gp = *g;
>  LONG bp = *b;
>  LONG v  = bp - rp;
>  LONG t  = rp - gp + (v >> 1);
>  LONG y  = gp + (t >> 1);
>  LONG u  = -t;
> 
> And this is the backwards transform:
> 
> u         = -u;            // this was called t above
> y        -= u >> 1;        // restore g. yp is now == g
> u        += y - (v >> 1); // this restores r. up is now == r
> v        += u;             // this restores b
> r         = u
> g         = y
> b         = v
> 
> HTHH,
> 	Thomas

Thanks, Thomas. The wiki gets the detailed response
https://en.wikipedia.org/wiki/YCgCo

[toc] | [prev] | [standalone]


Back to top | Article view | sci.image.processing


csiph-web