[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re:
From: |
Jaroslav Hajek |
Subject: |
Re: |
Date: |
Mon, 4 Aug 2008 10:26:49 +0200 |
On Mon, Aug 4, 2008 at 6:55 AM, bharat pathak <address@hidden> wrote:
> I have written a function to convert rgb to ycbcr. if I call this function
> with rgb matrix being 512x512x3 then it takes 2.4 seconds to execute
> this code. what is the way in which I can make this run faster?
>
> I have also attached the main program where this function is called.
>
> #######################################################################
>
> function ycbcr = rgb2ycbcr(rgb)
>
> red = rgb(:,:,1);
> grn = rgb(:,:,2);
> blu = rgb(:,:,3);
>
> 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;
>
> ycbcr(:,:,1) = y;
> ycbcr(:,:,2) = cb;
> ycbcr(:,:,3) = cr;
>
> endfunction
>
>
ycbcr = round (reshape (rgb, [], 3) * ([77, 150, 29; -44, -87, 131;
131, -110, -21]/256).');
ycbcr += ones (rows(ycbcr), 1) * [16,128,128]; % or [16,128,128]/256
as soren suggested.
ycbcr = reshape (ycbcr, size (rgb));
regards
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://www.cae.wisc.edu/mailman/listinfo/help-octave
>
>
--
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz
- [no subject], bharat pathak, 2008/08/04
- Re:, soren, 2008/08/04
- Re: ycbcr = rgb2ycbcr(rgb), Wolfgang Schechinger, 2008/08/04
- Re:, Francesco Potorti`, 2008/08/04
- Re:,
Jaroslav Hajek <=
- 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
- Prev by Date:
Re:
- Next by Date:
Re:
- Previous by thread:
Re:
- Next by thread:
Re:
- Index(es):