changeset 11685:4c9ab739b7c8 octave-forge

image: remove functions moved to Octave core and dependent on >= 3.8 * cmpermute: moved to core * cmunique: moved to core * iscolormap: moved to core * rgbplot: moved to core * NEWS: mention removed functions * DESCRIPTION: increased dependecy on Octave >= 3.8 (next release which will have the functions being removed)
author carandraug
date Sun, 05 May 2013 04:04:40 +0000
parents 0b616f53170d
children 9f74cc14b4e6
files main/image/DESCRIPTION main/image/NEWS main/image/inst/cmpermute.m main/image/inst/cmunique.m main/image/inst/iscolormap.m main/image/inst/rgbplot.m
diffstat 6 files changed, 11 insertions(+), 485 deletions(-) [+]
line wrap: on
line diff
--- a/main/image/DESCRIPTION	Sun May 05 03:54:10 2013 +0000
+++ b/main/image/DESCRIPTION	Sun May 05 04:04:40 2013 +0000
@@ -9,6 +9,6 @@
  The package also provides functions for feature extraction, image
  statistics, spatial and geometric transformations, morphological
  operations, linear filtering, and much more.
-Depends: octave (>= 3.6.0), signal (>= 1.2.0)
+Depends: octave (>= 3.8.0), signal (>= 1.2.0)
 License: GPLv3+, MIT, FreeBSD
 Url: http://octave.sf.net
--- a/main/image/NEWS	Sun May 05 03:54:10 2013 +0000
+++ b/main/image/NEWS	Sun May 05 04:04:40 2013 +0000
@@ -1,4 +1,4 @@
-Summary of important user-visible changes for image 2.0.1:
+Summary of important user-visible changes for image 2.2.0:
 -------------------------------------------------------------------
 
  ** The following functions are new:
@@ -12,6 +12,15 @@
       tformfwd
       tforminv
 
+ ** The following functions have been moved from the Octave Forge Image package
+    to GNU Octave core:
+
+      cmpermute
+      cmunique
+      iscolormap
+      rgbplot
+
+
  ** The following functions have been deprecated (see their help text
     for the recommended alternatives):
 
--- a/main/image/inst/cmpermute.m	Sun May 05 03:54:10 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,142 +0,0 @@
-## Copyright (C) 2004 Josep Mones i Teixidor
-## Copyright (C) 2012 Rik Wehbring 
-##
-## This file is part of Octave.
-##
-## Octave 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 3 of the License, or (at
-## your option) any later version.
-##
-## Octave 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.
-##
-## You should have received a copy of the GNU General Public License
-## along with Octave; see the file COPYING.  If not, see
-## <http://www.gnu.org/licenses/>.
-
-## -*- texinfo -*-
-## @deftypefn  {Function File} {[@var{Y}, @var{newmap}] =} cmpermute (@var{X}, @var{map})
-## @deftypefnx {Function File} {[@var{Y}, @var{newmap}] =} cmpermute (@var{X}, @var{map}, @var{index})
-## Reorder colors in a colormap.
-##
-## When called with only two arguments, @code{cmpermute} randomly rearranges
-## the colormap @var{map} and returns a new colormap @var{newmap}.  It also
-## returns the indexed image @var{Y} which is the equivalent of the original
-## input image @var{X} when displayed using @var{newmap}.  The input image
-## @var{X} must be an indexed image of class uint8 or double.
-##
-## When called with an optional third argument the order of colors in the
-## new colormap is defined by @var{index}.
-##
-## @strong{Caution:} @code{index} should not have repeated elements or the
-## function will fail.
-##
-## @end deftypefn
-
-## Author:  Josep Mones i Teixidor <jmones@puntbarra.com>
-
-function [Y, newmap] = cmpermute (X, map, index)
-
-  if (nargin < 2 || nargin > 3)
-    print_usage ();
-  endif
-
-  ## FIXME: Matlab only accepts 2 types.  Expand to uint16 & single??
-  if (! (isa (X, "uint8") || isa (X, "double")))
-    error ("cmpermute: X must be of class uint8 or double");
-  endif
-
-  if (! isreal (X) || issparse (X)
-      || (isfloat (X) && (any (X(:) < 1 || any (X(:) != fix (X(:)))))))
-    error ("cmpermute: X must be an indexed image");
-  endif
-
-  if (! isnumeric (map) || iscomplex (map)
-      || ndims (map) != 2 || columns (map) != 3
-      || any (map(:) < 0) || any (map(:) > 1))
-    error ("cmpermute: MAP must be a valid colormap");
-  endif
-
-  if (nargin < 3)
-    index = randperm (rows (map));
-  elseif (! isvector (index) || length (index) != rows (map))
-    error ("cmpermute: invalid parameter INDEX");
-  endif
-
-  ## new colormap
-  newmap = map(index,:);
-
-  ## build reverse index
-  rindex = zeros (size (index));
-  rindex(index) = 1:length (index);
- 
-  ## adapt indices
-  if (isa (X, "uint8"))
-    rindex = uint8 (rindex-1);
-    ## 0-based indices
-    Y = rindex(double (X) + 1);
-  else
-    Y = rindex(X);
-  endif
-
-endfunction
-
-%!demo
-%! [Y, newmap] = cmpermute ([1:4], hot (4), 4:-1:1)
-%! ## colormap will be arranged in reverse order (so will image)
-
-%!shared X, map
-%! X = uint8 (magic (16));
-%! [X, map] = cmunique (X);
-
-%!test # random permutation, 0-based index
-%! [Y, newmap] = cmpermute (X, map);
-%! ## test we didn't lose colors
-%! assert (sort (map), sortrows (newmap)); 
-%! ## test if images are equal
-%! assert (map(double (X)+1), newmap(double (Y)+1));
-
-%!test # reverse map, 0-based index
-%! [Y, newmap] = cmpermute (X, map, rows (map):-1:1);
-%! ## we expect a reversed colormap
-%! assert (flipud (newmap), map);
-%! ## we expect reversed indices in image
-%! assert (X, max (Y(:)) - Y);
-
-%!shared X,map
-%! X = uint16 (magic (20));
-%! [X, map] = cmunique (X);
-
-%!test # random permutation, 1-based index
-%! [Y, newmap] = cmpermute (X, map);
-%! ## test we didn't lose colors
-%! assert (sort (map), sortrows (newmap)); 
-%! ## test if images are equal
-%! assert (map(X), newmap(Y));
-
-%!test # reverse map, 1-based index
-%! [Y, newmap] = cmpermute (X, map, rows (map):-1:1);
-%! ## we expect a reversed colormap
-%! assert (newmap (rows (newmap):-1:1,:), map);
-%! ## we expect reversed indices in image
-%! assert (X, max (Y(:)) + 1 - Y);
-
-## Test input validation
-%!error cmpermute ()
-%!error cmpermute (1,2,3,4)
-%!error <X must be of class uint8> cmpermute (uint16 (magic (16)), jet (256))
-%!error <X must be an indexed image> cmpermute (1+i, jet (256))
-%!error <X must be an indexed image> cmpermute (sparse (1), jet (256))
-%!error <X must be an indexed image> cmpermute (0, jet (256))
-%!error <X must be an indexed image> cmpermute (1.5, jet (256))
-%!error <MAP must be a valid colormap> cmpermute (1, "a")
-%!error <MAP must be a valid colormap> cmpermute (1, i)
-%!error <MAP must be a valid colormap> cmpermute (1, ones (3,3,3))
-%!error <MAP must be a valid colormap> cmpermute (1, ones (3,2))
-%!error <MAP must be a valid colormap> cmpermute (1, [-1 1 1])
-%!error <MAP must be a valid colormap> cmpermute (1, [2 1 1])
-%!error <invalid parameter INDEX> cmpermute (1, [0 1 0;1 0 1], ones (3))
-%!error <invalid parameter INDEX> cmpermute (1, [0 1 0;1 0 1], 1:3)
--- a/main/image/inst/cmunique.m	Sun May 05 03:54:10 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,203 +0,0 @@
-## Copyright (C) 2004 Josep Mones i Teixidor
-## Copyright (C) 2012 Rik Wehbring 
-##
-## This file is part of Octave.
-##
-## Octave 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 3 of the License, or (at
-## your option) any later version.
-##
-## Octave 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.
-##
-## You should have received a copy of the GNU General Public License
-## along with Octave; see the file COPYING.  If not, see
-## <http://www.gnu.org/licenses/>.
-
-## -*- texinfo -*-
-## @deftypefn  {Function File} {[@var{Y}, @var{newmap}] =} cmunique (@var{X}, @var{map})
-## @deftypefnx {Function File} {[@var{Y}, @var{newmap}] =} cmunique (@var{RGB})
-## @deftypefnx {Function File} {[@var{Y}, @var{newmap}] =} cmunique (@var{I})
-## Convert an input image @var{X} to an ouput indexed image @var{Y} which uses
-## the smallest colormap possible @var{newmap}.
-##
-## When the input is an indexed image (@var{X} with colormap @var{map}) the 
-## output is a colormap @var{newmap} from which any repeated rows have been
-## eliminated.  The output image, @var{Y}, is the original input image with
-## the indices adjusted to match the new, possibly smaller, colormap.
-##
-## When the input is an RGB image (an @nospell{MxNx3} array), the output
-## colormap will contain one entry for every unique color in the original image.
-## In the worst case the new map could have as many rows as the number of
-## pixels in the original image.
-##
-## When the input is a grayscale image @var{I}, the output colormap will
-## contain one entry for every unique intensity value in the original image.
-## In the worst case the new map could have as many rows as the number of
-## pixels in the original image.
-##
-## Implementation Details:
-##
-## @var{newmap} is always an Mx3 matrix, even if the input image is
-## an intensity grayscale image @var{I} (all three RGB planes are
-## assigned the same value).
-##
-## The output image is of class uint8 if the size of the new colormap is
-## less than or equal to 256.  Otherwise, the output image is of class double.
-##
-## @seealso{rgb2ind, gray2ind}
-## @end deftypefn
-
-
-## Author:  Josep Mones i Teixidor <jmones@puntbarra.com>
-
-function [Y, newmap] = cmunique (X, map)
-
-  if (nargin < 1 || nargin > 2)
-    print_usage ();
-  endif
-
-  cls = class (X);
-  ## FIXME: Documentation accepts only 3 classes.  Could easily add 'single'.
-  if (! any (isa (X, {"uint8", "uint16", "double"})))
-    error ("cmunique: X is of invalid data type '%s'", cls);
-  endif
-
-  if (nargin == 2)
-    ## (X, map) case
-    if (! isnumeric (map) || iscomplex (map)
-        || ndims (map) != 2 || columns (map) != 3
-        || any (map(:) < 0) || any (map(:) > 1))
-      error ("cmunique: MAP must be a valid colormap");
-    endif
-    [newmap,i,j] = unique (map, "rows");  # calculate unique colormap
-    if (isa (X, "double"))
-      Y = j(X);               # find new indices
-    else
-      Y = j(double (X) + 1);  # find new indices
-    endif
-  else
-    switch (size (X,3))
-      case (1)
-        ## I case
-        [newmap,i,j] = unique (X);               # calculate unique colormap
-        newmap = repmat (newmap,1,3);            # get a RGB colormap
-        Y = reshape (j, rows (X), columns (X));  # Y is j reshaped
-      case (3)
-        ## RGB case
-        ## build a map with all values
-        map = [X(:,:,1)(:), X(:,:,2)(:), X(:,:,3)(:)];
-        [newmap,i,j] = unique (map, "rows");     # calculate unique colormap
-        Y = reshape (j, rows (X), columns (X));  # Y is j reshaped
-      otherwise
-        error ("cmunique: X is not a valid image");
-    endswitch
-    
-    ## if image was uint8 or uint16 we have to convert newmap to [0,1] range
-    if (! isa (X, "double"))
-      newmap = double (newmap) / double (intmax (class (X)));
-    endif
-  endif
-
-  if (rows (newmap) <= 256)
-    ## convert Y to uint8 (0-based indices then)
-    Y = uint8 (Y-1);
-  endif
-
-endfunction
-
-
-%!demo
-%! [Y, newmap] = cmunique ([1:4;5:8], [hot(4);hot(4)])
-%! ## Both rows are equal since map maps colors to the same value
-%! ## cmunique will give the same indices to both
-
-## Check that output is uint8 in short colormaps
-%!test
-%! [Y, newmap] = cmunique ([1:4;5:8], [hot(4);hot(4)]);
-%! assert (Y, uint8 ([0:3;0:3]));
-%! assert (newmap, hot (4));
-
-## Check that output is double in bigger
-%!test
-%! [Y, newmap] = cmunique ([1:300;301:600], [hot(300);hot(300)]);
-%! assert (Y, [1:300;1:300]);
-%! assert (newmap, hot (300));
-
-## Check boundary case 256
-%!test
-%! [Y, newmap] = cmunique ([1:256;257:512], [hot(256);hot(256)]);
-%! assert (Y, uint8 ([0:255;0:255]));
-%! assert (newmap, hot (256));
-
-## Check boundary case 257
-%!test
-%! [Y, newmap] = cmunique ([1:257;258:514], [hot(257);hot(257)]);
-%! assert (Y, [1:257;1:257]);
-%! assert (newmap, hot (257));
-
-## Random RGB image
-%!test
-%! RGB = rand (10,10,3);
-%! [Y, newmap] = cmunique (RGB);
-%! assert (RGB(:,:,1), newmap(:,1)(Y+1));
-%! assert (RGB(:,:,2), newmap(:,2)(Y+1));
-%! assert (RGB(:,:,3), newmap(:,3)(Y+1));
-
-## Random uint8 RGB image
-%!test
-%! RGB = uint8 (rand (10,10,3)*255);
-%! RGBd = double (RGB) / 255;
-%! [Y, newmap] = cmunique (RGB);
-%! assert (RGBd(:,:,1), newmap(:,1)(Y+1));
-%! assert (RGBd(:,:,2), newmap(:,2)(Y+1));
-%! assert (RGBd(:,:,3), newmap(:,3)(Y+1));
-
-## Random uint16 RGB image
-%!test
-%! RGB = uint16 (rand (10,10,3)*65535);
-%! RGBd = double (RGB) / 65535;
-%! [Y, newmap] = cmunique (RGB);
-%! assert (RGBd(:,:,1), newmap(:,1)(Y+1));
-%! assert (RGBd(:,:,2), newmap(:,2)(Y+1));
-%! assert (RGBd(:,:,3), newmap(:,3)(Y+1));
-
-## Random I image
-%!test
-%! I = rand (10,10);
-%! [Y, newmap] = cmunique (I);
-%! assert (I, newmap(:,1)(Y+1));
-%! assert (I, newmap(:,2)(Y+1));
-%! assert (I, newmap(:,3)(Y+1));
-
-## Random uint8 I image
-%!test
-%! I = uint8 (rand (10,10)*256);
-%! Id = double (I) / 255;
-%! [Y, newmap] = cmunique (I);
-%! assert (Id, newmap(:,1)(Y+1));
-%! assert (Id, newmap(:,2)(Y+1));
-%! assert (Id, newmap(:,3)(Y+1));
-
-## Random uint16 I image
-%!test
-%! I = uint16 (rand (10,10)*65535);
-%! Id = double (I) / 65535;
-%! [Y,newmap] = cmunique (I);
-%! assert (Id,newmap (:,1)(Y+1));
-%! assert (Id,newmap (:,2)(Y+1));
-%! assert (Id,newmap (:,3)(Y+1));
-
-## Test input validation
-%!error cmpermute ()
-%!error cmpermute (1,2,3)
-%!error <X is of invalid data type> cmunique (single (magic (16)))
-%!error <MAP must be a valid colormap> cmunique (1, "a")
-%!error <MAP must be a valid colormap> cmunique (1, i)
-%!error <MAP must be a valid colormap> cmunique (1, ones (3,3,3))
-%!error <MAP must be a valid colormap> cmunique (1, ones (3,2))
-%!error <MAP must be a valid colormap> cmunique (1, [-1 1 1])
-%!error <MAP must be a valid colormap> cmunique (1, [2 1 1])
--- a/main/image/inst/iscolormap.m	Sun May 05 03:54:10 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-## Copyright (C) 2012 Carnë Draug
-##
-## This file is part of Octave.
-##
-## Octave 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 3 of the License, or (at
-## your option) any later version.
-##
-## Octave 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.
-##
-## You should have received a copy of the GNU General Public License
-## along with Octave; see the file COPYING.  If not, see
-## <http://www.gnu.org/licenses/>.
-
-## -*- texinfo -*-
-## @deftypefn {Function File} {} iscolormap (@var{cmap})
-## Return true if @var{cmap} is a colormap.
-##
-## A colormap is an @var{n} row by 3 column matrix.  The columns contain red,
-## green, and blue intensities respectively.  All entries must be between 0
-## and 1 inclusive.
-##
-## @seealso{colormap, rgbplot}
-## @end deftypefn
-
-## Author: Carnë Draug <carandraug+dev@gmail.com>
-
-function retval = iscolormap (cmap)
-
-  if (nargin != 1)
-    print_usage;
-  endif
-
-  retval = (isnumeric (cmap) && isreal (cmap) &&
-            columns (cmap) == 3 && ndims (cmap) == 2 && isa (cmap, "double") &&
-            min (cmap(:)) >= 0 && max (cmap(:)) <= 1);
-
-endfunction
-
-%!assert (iscolormap (jet (64)))
-%!assert (iscolormap ({0 1 0}), false)
-%!assert (iscolormap ([0 1i 0]), false)
-%!assert (iscolormap (ones (3,4)), false)
-%!assert (iscolormap (ones (3,3,3)), false)
-%!assert (iscolormap (single (jet (64))), false)
-%!assert (iscolormap ([0 0 -2]), false)
-%!assert (iscolormap ([0 0 2]), false)
--- a/main/image/inst/rgbplot.m	Sun May 05 03:54:10 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-## Copyright (C) 2012 Rik Wehbring
-## Copyright (C) 2012 Carnë Draug
-##
-## This file is part of Octave.
-##
-## Octave 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 3 of the License, or (at
-## your option) any later version.
-##
-## Octave 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.
-##
-## You should have received a copy of the GNU General Public License
-## along with Octave; see the file COPYING.  If not, see
-## <http://www.gnu.org/licenses/>.
-
-## -*- texinfo -*-
-## @deftypefn  {Function File} {} rgbplot (@var{cmap})
-## @deftypefnx {Function File} {} rgbplot (@var{cmap}, @var{style})
-## @deftypefnx {Function File} {@var{h} =} rgbplot (@dots{})
-## Plot the components of a colormap.
-##
-## Two different @var{style}s are available for displaying the @var{cmap}:
-## @table @asis
-## @item profile (default)
-## Plots the RGB line profile of the colormap for each of the channels (red,
-## green and blue) with the plot lines colored appropriately.  Each line
-## represents the intensity of each RGB components across the colormap.
-##
-## @item composite
-## Draws the colormap across the X axis so that the actual colors are visible
-## rather than the individual color components.
-##
-## @end table
-##
-## Run @code{demo rgbplot} for a comparison display.
-##
-## The optional return value @var{h} is a graphics handle to the created plot.
-##
-## @seealso{colormap}
-## @end deftypefn
-
-function retval = rgbplot (cmap, style)
-
-  if (nargin < 1 || nargin > 2)
-    print_usage ();
-  endif
-
-  if (! iscolormap (cmap))
-    error ("rgbplot: CMAP must be a colormap");
-  elseif (! ischar (style))
-    error ("rgbplot: STYLE must be a string");
-  endif
-
-  switch tolower (style)
-    case "profile"
-      h = plot (cmap(:,1),"r", cmap(:,2),"g", cmap(:,3),"b");
-      set (gca, 'ytick', 0:0.1:1);
-    case "composite"
-      h = image (1:rows(cmap));
-      set (gca, 'ytick', []);
-      colormap (cmap);
-    otherwise
-      error ("rgbplot: unknown style `%s'", style);
-  endswitch
-  xlabel ("color index");
-
-  if (nargout > 0)
-    retval = h;
-  endif
-
-endfunction
-
-%!demo
-%! clf;
-%! subplot (1, 2, 1);
-%! rgbplot (ocean, "profile");
-%! subplot (1, 2, 2)
-%! rgbplot (ocean, "composite");
-
-%%test input validation
-%!error rgbplot ()
-%!error rgbplot (1,2)
-%!error <CMAP must be a colormap> rgbplot ({0 1 0})