2011/5/31 santiago reyes <mailalcu...@gmail.com>:
> Carnë
> I attach the file with the changes that you want.
> I hope this work to the community.
Hi Santiago,
I added your function to the image package. It will be available on
the next release. Thanks for your contribution, it's very appreciated.
I did a few changes to your code:
* As David Bateman suggested I removed the for loops and replaced with
im(:,:,1) which made the function much much faster (500x times faster
in a 100x100 image and 360x faster in a 500x500 image). That one
change made that the function took 0.2sec instead of 72sec in the
500x500 image example.
* changed the name of the variable dimensiones to it's english equivalent
* changed the way you check for errors
* removed the im_cal variable, no point in keeping both im and im_cal on memory
* removed the cpermute on seealso (we don't have that function)
* I added your e-mail to the copyright notice
* added a note to the help text saying that it only works with uint8 images
On this last point, if the users uses a uint16 image as input, the
output result will be uint8. But will it be wrong or just on another
type? If it's wrong, maybe we should check if the input is uint8 and
return an error if it's not.
Carnë
## Copyright (C) 2011 Santiago Reyes González <mailalcu...@gmail.com>
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License
## as published by the Free Software Foundation; either version 2
## of the License, or (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
## -*- texinfo -*-
## @deftypefn {Function File} @var{B} = rgb2ycbcr(@var{A})
## Perform colour convertion from RGB to YCbCr on a given image.
##
## The image @var{A} must be a NxMx3 image. The conversion
## The convertion changes the image from the RGB color model to YCbCr e.g.
## @example
## imOut = rgb2ycbcr(imIn);
## @end example
## Currently this function only works with @samp{uint8} and will always return
## an @samp{uint8} matrix.
## @seealso{cmunique}
## @end deftypefn
function im_out = rgb2ycbcr_mod(im)
if (nargin != 1)
print_usage;
elseif (length(size(im)) != 3 || size(im,3) != 3)
error("image must be NxMx3");
endif
im = im2double(im);
im_out(:,:,1) = uint8(floor(77*im(:,:,1) + 150*im(:,:,2) + 29*im(:,:,3)));
im_out(:,:,2) = uint8(floor(((-44*im(:,:,1) - 87*im(:,:,2) + 131*im(:,:,3))/256 + 0.5)*256));
im_out(:,:,3) = uint8(floor(((131*im(:,:,1) - 110*im(:,:,2) - 21*im(:,:,3))/256 + 0.5)*256));
endfunction
------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today.
http://p.sf.net/sfu/quest-sfdev2dev
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev