soren at hauberg.org soren at hauberg.org
Mon Aug 4 03:59:51 CDT 2008


By the way, it would be great if you would consider contributing your  
code (once you've finished it up) to the Octave-Forge 'image' package,  
as we currently don't have that function.

Søren

Quoting bharat pathak <bharat at arithos.com>:

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





More information about the Help-octave mailing list