help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ycbcr = rgb2ycbcr(rgb)


From: Wolfgang Schechinger
Subject: Re: ycbcr = rgb2ycbcr(rgb)
Date: Mon, 04 Aug 2008 09:48:43 +0200

Dear Bharat,

as you probably want integers anyway, have you considered to drop the lowest 8 
bits or to do the whole conversion with integers?

Wo



instead of dividing by 256, -------- Original-Nachricht --------
> Datum: Mon, 4 Aug 2008 10:25:17 +0530
> Von: "bharat pathak" <address@hidden>
> An: address@hidden
> Betreff: 

> 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
> 
>     

-- 
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten 
Browser-Versionen downloaden: http://www.gmx.net/de/go/browser


reply via email to

[Prev in Thread] Current Thread [Next in Thread]