[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re:
From: |
soren |
Subject: |
Re: |
Date: |
Mon, 04 Aug 2008 09:16:20 +0200 |
User-agent: |
Internet Messaging Program (IMP) H3 (4.2-RC2) |
Hmm, I'm surprised that your code is slow. You could try something
like this (untested code):
function ycbcr = rgb2ycbcr(rgb)
A = [77, 150, 29; -44, -87, 131; 131, -110, -21]/256;
tmp = round(A*[rgb(:,:,1)(:), rgb(:,:,2)(:), rgb(:,:,3)(:)].');
ycbcr = cat (3, reshape (tmp (1,:), s), reshape (tmp (2,:), s),
reshape (tmp (3,:), s));
endfunction
but I doubt it'll be much faster. Also, there is one detail about your code:
Quoting bharat pathak <address@hidden>:
ycbcr(:,:,1) = y;
ycbcr(:,:,2) = cb;
ycbcr(:,:,3) = cr;
if you swap the order of these commands things will be slightly faster
because you don't have to resize 'ycbcr'.
Also, in the following part
y = round((77*red + 150*grn + 29*blu)/256) + 16;
cb = round((-44*red - 87*grn + 131*blu)/256) + 128;
cr = round((131*red - 110*grn - 21*blu)/256) + 128;
Now, I can't remember my color conversions, but this looks wrong.
Shouldn't the translations [16, 128, 128] also be divided by 256?
Søren
- [no subject], bharat pathak, 2008/08/04
- Re:,
soren <=
- Re: ycbcr = rgb2ycbcr(rgb), Wolfgang Schechinger, 2008/08/04
- Re:, Francesco Potorti`, 2008/08/04
- Re:, Jaroslav Hajek, 2008/08/04
- Re:, soren, 2008/08/04
- Re: Re:, bharat pathak, 2008/08/04
- Re: Re:, soren, 2008/08/04
- Re:, Bill Denney, 2008/08/04
- Re: Re:, Jaroslav Hajek, 2008/08/04