From: <ha...@us...> - 2008-10-01 09:51:53
|
Revision: 5325 http://octave.svn.sourceforge.net/octave/?rev=5325&view=rev Author: hauberg Date: 2008-10-01 09:51:38 +0000 (Wed, 01 Oct 2008) Log Message: ----------- Remove imread and imwrite as they have been moved to Octave Modified Paths: -------------- trunk/octave-forge/main/image/DESCRIPTION trunk/octave-forge/main/image/src/Makeconf.in trunk/octave-forge/main/image/src/configure.base Removed Paths: ------------- trunk/octave-forge/main/image/inst/imread.m trunk/octave-forge/main/image/inst/imwrite.m trunk/octave-forge/main/image/src/__magick_read__.cc Modified: trunk/octave-forge/main/image/DESCRIPTION =================================================================== --- trunk/octave-forge/main/image/DESCRIPTION 2008-09-30 17:56:02 UTC (rev 5324) +++ trunk/octave-forge/main/image/DESCRIPTION 2008-10-01 09:51:38 UTC (rev 5325) @@ -5,15 +5,13 @@ Maintainer: The Octave Community Title: Image Processing Description: The Octave-forge Image package provides functions for - reading, writing, and processing images. The package supports - almost all image formats through the use of ImageMagick. + processing images. The package also provides functions for feature extraction, image statistics, spatial and geometric transformations, morphological operations, linear filtering, and much more. -Depends: octave (>= 2.9.10) +Depends: octave (>= 3.1.51) Autoload: yes BuildRequires: png-devel BuildRequires: jpeg-devel -SystemRequirements: ImageMagick License: GPL version 2 or later Url: http://octave.sf.net Deleted: trunk/octave-forge/main/image/inst/imread.m =================================================================== --- trunk/octave-forge/main/image/inst/imread.m 2008-09-30 17:56:02 UTC (rev 5324) +++ trunk/octave-forge/main/image/inst/imread.m 2008-10-01 09:51:38 UTC (rev 5325) @@ -1,170 +0,0 @@ -## Copyright (C) 2002 Andy Adler -## -## 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, or (at your option) -## any later version. USE THIS SOFTWARE AT YOUR OWN RISK. - -## -*- texinfo -*- -## @deftypefn {Function File} {@var{I} =} imread(@var{filename}) -## Read images from various file formats. -## -## The size and numeric class of the output depends on the -## format of the image. A colour image is returned as an -## MxNx3 matrix. Grey-level and black-and-white images are -## of size MxN. -## The colour depth of the image determines the numeric -## class of the output: 'uint8' or 'uint16' for grey -## and colour, and 'logical' for black and white. -## -## Note: For image formats other than jpeg and png, the -## ImageMagick "convert" and "identify" utilities -## are needed. ImageMagick can be found at www.imagemagick.org -## @end deftypefn - -## Author: Andy Adler -## -## Modified: Stefan van der Walt <st...@su...> -## Date: 24 January 2005 -## -## Modified: Thomas Weber <tho...@gm...> -## Date: 20 December 2006 -## Change parsing of imagemagick's output to get the 'color' depth for grayscale -## images -## -## Modified Kristian Rumberg <kri...@gm...> -## Date 2 April 2008 -## Imread now works with BMP's created with "convert inputimage out.bmp" -## (tested with stable release Octave 3.0 in GNU/Linux and Windows XP), -## modified the calling parameters to identify and convert - -function varargout = imread(filename, varargin) - if (nargin != 1) - usage("I = imread(filename)") - endif - - if !ischar (filename) - error("imread: filename must be a string") - endif - - filename = tilde_expand(filename); - fn = file_in_path(IMAGE_PATH, filename); - if isempty(fn) - error("imread: cannot find %s", filename); - endif - - - [ig, ig, ext] = fileparts(fn); - ext = upper(ext); - - ## divert jpegs and pngs to "jpgread" and "pngread" - if ( file_in_loadpath("jpgread.oct") && - (strcmp(ext, ".JPG") || strcmp(ext, ".JPEG")) ) - varargout{1} = jpgread(fn); - break - endif - if ( file_in_loadpath("pngread.oct") && (strcmp(ext, ".PNG")) ) - varargout{1} = pngread(fn); - break - endif - - ## alternately, use imagemagick - if ( file_in_loadpath("__magick_read__.oct") ) - [varargout{1:nargout}] = __magick_read__(fn, varargin{:}); - break - endif - - [sys, ident] = system(sprintf('identify -verbose \"%s\" | grep -e "bit" -e Type', fn)); - if (sys != 0) - error("imread: error running ImageMagick's 'identify' on %s", fn); - endif - depth = re_grab("([[:digit:]]{1,2})-bit", ident); - imtype = re_grab("Type: ([[:alpha:]]*)", ident); - - depth = str2num(depth); - if isempty(depth) || (pow2(nextpow2(depth)) != depth) - error("imread: invalid image depth %s", depth); - endif - - if !( strcmp(imtype, "Bilevel") || strcmp(imtype, "Grayscale") || - strcmp(imtype, "TrueColor") || strcmp(imtype, "TrueColorMatte") || - strcmp(imtype, "Palette") ) - error("imread: unknown image type '%s'", imtype); - endif - - switch (imtype) - case {"Bilevel"} - fmt = "pgm"; - case {"Grayscale"} - fmt = "pgm"; - case {"TrueColor", "TrueColorMatte", "Palette"} - fmt = "ppm"; - endswitch - - ## Why are pipes so slow? - ## cmd = sprintf("convert -flatten -strip %s %s:-", fn, fmt); - - tmpf = [tmpnam(), ".", fmt]; - ##cmd = sprintf("convert -flatten -strip +compress '%s' '%s' 2>/dev/null", - ## fn, tmpf); - cmd = sprintf("convert -strip \"%s\" \"%s\"", fn, tmpf); - - sys = system(cmd); - if (sys != 0) - error("imread: error running ImageMagick's 'convert'"); - unlink(tmpf); - endif - - try - fid = fopen(tmpf, "rb"); - catch - unlink(tmpf); - error("imread: could not open temporary file %s", tmpf) - end_try_catch - - fgetl(fid); # P5 or P6 (pgm or ppm) - [width, height] = sscanf(fgetl(fid), "%d %d", "C"); - fgetl(fid); # ignore max components - - if (depth == 16) - ## PGM format has MSB first, i.e. big endian - [data, count] = fread(fid, "uint16", 0, "ieee-be"); - else - [data, count] = fread(fid, "uint8"); - endif - - fclose(fid); - unlink(tmpf); - - if (any(strcmp(imtype, {"TrueColor", "TrueColorMatte", "Palette"}))) - channels = 3; - else - channels = 1; - endif - if (count != width*height*channels) - error("imread: image data chunk has invalid size %i != %i*%i*%i == %i", - count, width, height, channels, width*height*channels); - endif - - varargout = {}; - switch (imtype) - case {"Bilevel"} - varargout{1} = logical(reshape(data, width, height)'); - case {"Grayscale"} - varargout{1} = uint8(reshape(data, width, height)'); - case {"TrueColor", "TrueColorMatte", "Palette"} - varargout{1} = cat(3, reshape(data(1:3:end), width, height)', - reshape(data(2:3:end), width, height)', - reshape(data(3:3:end), width, height)'); - eval(sprintf("varargout{1} = uint%d(varargout{1});", depth)); - endswitch -endfunction - -function value = re_grab(re, str) - T = regexp(str,re,'tokens'); - if (isempty(T)) - value = ""; - else - value = T{1}{1}; - endif -endfunction Deleted: trunk/octave-forge/main/image/inst/imwrite.m =================================================================== --- trunk/octave-forge/main/image/inst/imwrite.m 2008-09-30 17:56:02 UTC (rev 5324) +++ trunk/octave-forge/main/image/inst/imwrite.m 2008-10-01 09:51:38 UTC (rev 5325) @@ -1,401 +0,0 @@ -## Copyright (C) 2002 Andy Adler -## -## 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, or (at your option) -## any later version. USE THIS SOFTWARE AT YOUR OWN RISK. - -## -*- texinfo -*- -## @deftypefn {Function File} imwrite(@var{fname}, @var{img}) -## Write image from octave to various file formats -## -## Note: this requires the ImageMagick "convert" utility. -## get this from www.imagemagick.org if required -## additional documentation of options is available from the -## convert man page. -## -## @deftypefnx{Function File} imwrite(@var{fname}, @var{img}) -## @var{img} is a greyscale (0-255) of image in fname. -## @deftypefnx{Function File} imwrite(@var{fname}, @var{img}, @var{map}) -## @var{map} is a matrix of [r,g,b], 0-1 triplesm and -## @var{img} is a matrix on indeces into map. -## @deftypefnx{Function File} imwrite(@var{fname}, @var{r}, @var{g}, @var{b}); -## @var{r}, @var{g}, @var{b} are red, green, blue (0-255) compondents. -## -## Formats for image fname -## @enumerate -## @item -## Simple guess from extention, i.e. "fig.jpg", "blah.gif". -## @item -## Specify explicitly, i.e. "jpg:fig.jpg", "gif:blah.gif". -## @item -## Specify subimage for multi-image format: "tiff:file.tif[3]". -## @item -## Raw images (row major format) specify geometry: "raw:img[256x180]". -## @end enumerate -## -## @deftypefnx{Function File} imwrite(@var{fname}, @var{img}, @var{options}) -## @deftypefnx{Function File} imwrite(@var{fname}, @var{img}, @var{map}, @var{options}) -## @deftypefnx{Function File} imwrite(@var{fname}, @var{r}, @var{g}, @var{b}, @var{options}); -## It is possible to give extra options to imwrite, for example: -## @example -## options= ["-rotate 25"; -## "-crop 200x200+150+150"; -## "-sample 200%" ]; -## @end example -## will rotate, crop, and then expand the image. -## note that the order of operations is important -## -## The following options are supported -## @table @code -## @item -antialias -## remove pixel-aliasing -## @item -background color -## background color -## @item -blur geometry -## blur the image -## @item -border geometry -## surround image with a border of color -## @item -bordercolor color -## border color -## @item -box color -## color for annotation bounding box -## @item -charcoal radius -## simulate a charcoal drawing -## @item -colorize value -## colorize the image with the fill color -## @item -colors value -## preferred number of colors in the image -## @item -colorspace type -## alternate image colorspace -## @item -comment string -## annotate image with comment -## @item -compress type -## type of image compression -## @item -contrast -## enhance or reduce the image contrast -## @item -crop geometry -## preferred size and location of the cropped image -## @item -density geometry -## vertical and horizontal density of the image -## @item -depth value -## depth of the image -## @item -despeckle -## reduce the speckles within an image -## @item -dispose method -## GIF disposal method -## @item -dither -## apply Floyd/Steinberg error diffusion to image -## @item -draw string -## annotate the image with a graphic primitive -## @item -edge radius -## apply a filter to detect edges in the image -## @item -emboss radius -## emboss an image -## @item -enhance -## apply a digital filter to enhance a noisy image -## @item -equalize -## perform histogram equalization to an image -## @item -fill color -## color to use when filling a graphic primitive -## @item -filter type -## use this filter when resizing an image -## @item -flip -## flip image in the vertical direction -## @item -flop -## flop image in the horizontal direction -## @item -font name -## font for rendering text -## @item -frame geometry -## surround image with an ornamental border -## @item -fuzz distance -## colors within this distance are considered equal -## @item -gamma value -## level of gamma correction -## @item -geometry geometry -## perferred size or location of the image -## @item -gaussian geometry -## gaussian blur an image -## @item -gravity type -## vertical and horizontal text placement -## @item -implode amount -## implode image pixels about the center -## @item -intent type -## Absolute, Perceptual, Relative, or Saturation -## @item -interlace type -## None, Line, Plane, or Partition -## @item -label name -## assign a label to an image -## @item -level value -## adjust the level of image contrast -## @item -list type -## Color, Delegate, Format, Magic, Module, or Type -## @item -map filename -## transform image colors to match this set of colors -## @item -matte -## store matte channel if the image has one -## @item -median radius -## apply a median filter to the image -## @item -modulate value -## vary the brightness, saturation, and hue -## @item -monochrome -## transform image to black and white -## @item -morph value -## morph an image sequence -## @item -negate -## replace every pixel with its complementary color -## @item -noise radius -## add or reduce noise in an image -## @item -normalize -## transform image to span the full range of colors -## @item -opaque color -## change this color to the fill color -## @item -page geometry -## size and location of an image canvas -## @item -paint radius -## simulate an oil painting -## @item -profile filename -## add ICM or IPTC information profile to image -## @item -quality value -## JPEG/MIFF/PNG compression level -## @item -raise value -## lighten/darken image edges to create a 3-D effect -## @item -region geometry -## apply options to a portion of the image -## @item -roll geometry -## roll an image vertically or horizontally -## @item -rotate degrees -## apply Paeth rotation to the image -## @item -sample geometry -## scale image with pixel sampling -## @item -scale geometry -## resize image -## @item -segment values -## segment an image -## @item -seed value -## pseudo-random number generator seed value -## @item -shade degrees -## shade the image using a distant light source -## @item -sharpen geometry -## sharpen the image -## @item -shave geometry -## shave pixels from the image edges -## @item -shear geometry -## slide one edge of the image along the X or Y axis -## @item -size geometry -## width and height of image -## @item -solarize threshold -## negate all pixels above the threshold level -## @item -spread amount -## displace image pixels by a random amount -## @item -stroke color -## color to use when stoking a graphic primitive -## @item -strokewidth value -## width of stroke -## @item -swirl degrees -## swirl image pixels about the center -## @item -texture filename -## name of texture to tile onto the image background -## @item -threshold value -## threshold the image -## @item -tile filename -## tile image when filling a graphic primitive -## @item -transparent color -## make this color transparent within the image -## @item -treedepth value -## depth of the color tree -## @item -type type -## image type -## @item -units type -## PixelsPerInch, PixelsPerCentimeter, or Undefined -## @item -unsharp geometry -## sharpen the image -## @end table -## @end deftypefn - -function imwrite(fname, p2, p3 ,p4 ,p5 ); - -try save_empty_list_elements_ok= empty_list_elements_ok; -catch save_empty_list_elements_ok= 0; -end -try save_warn_empty_list_elements= warn_empty_list_elements; -catch save_warn_empty_list_elements= 0; -end -unwind_protect -empty_list_elements_ok= 1; -warn_empty_list_elements= 0; - -# some older versions of octave didn't seem handle piped output correctly -usepipe=1; - -# Support matlabs input order -if (nargin >= 2 && ismatrix(fname) && ischar(p2)) - tmp = p2; - p2 = fname; - fname = tmp; -endif - -if ( nargin <= 1 ) || ... - ( ! ischar (fname)) || ... - ( nargin == 2 && ischar(p2) ) - usage([ ... - "imwrite( fname, img )\n", ... - "imwrite( fname, img, map )\n", ... - "imwrite( fname, r,g,b );\n", ... - "imwrite( fname, img, options )\n", ... - "imwrite( fname, img, map, options )\n", ... - "imwrite( fname, r,g,b, options );\n"]); -endif - -fname = tilde_expand(fname); - -# Put together the options string -# TODO: add some error checking to options -option_str=""; -n_mat= nargin-1; - -options= eval(sprintf("p%d",nargin)); -# process options strings if given -if ischar(options) - n_mat--; - for i= 1:size(options,1) - option_str=[option_str," ", options(i,:) ]; - end -elseif is_list( options ) - n_mat--; - for i= 1:length(options) - option_str=[option_str," ", nth(options,i) ]; - end -end - -[hig,wid] = size(p2); -if n_mat==1 - data= p2'; - outputtype="pgm"; - pnm_sig="P5"; -elseif n_mat==2 - img= p2'; - data= [ reshape(p3(img,1),1, hig*wid); - reshape(p3(img,2),1, hig*wid); - reshape(p3(img,3),1, hig*wid) ]; - outputtype="ppm"; - pnm_sig="P6"; -elseif n_mat==3 - data= [ reshape(p2',1, hig*wid); - reshape(p3',1, hig*wid); - reshape(p4',1, hig*wid) ]; - outputtype="ppm"; - pnm_sig="P6"; -else - error("imwrite: too many data matrices specified"); -end - -# Scale data depending on data type -switch(class(data)) -case "double" - data *= 255; -case "uint8" -case "uint16" - data /= 255; -otherwise - error("imwrite: unsupported data type %s", class(data)); -endswitch - -if strcmp([computer](9:13), "msdos") - _null = "null:"; - _apostroph = "\""; -else - _null = "/dev/null"; - _apostroph = "\""; -endif - -if usepipe - pname= sprintf("convert %s %s:- %c%s%c 2> %s", - option_str, outputtype, _apostroph, fname, _apostroph, _null); - fid= popen(pname ,'w'); - - if fid<0; - error('could not create image data. Is ImageMagick installed?'); - end -else - tnam= tmpnam(); - cmd= sprintf("convert %s %c%s:%s%c %c%s%c 2> %s", - option_str, _apostroph, outputtype, tnam, _apostroph, _apostroph, fname, _apostroph, _null); - fid= fopen(tnam, "wb"); -end - - fprintf(fid,"%s\n%d %d\n255\n",pnm_sig,wid,hig); - write_count= fwrite(fid,data(:)); - if write_count != prod(size(data)) - fclose(fid); - if ~usepipe - unlink(tnam); - end - error(['Problem writing image: ', fname ]); - end - - fclose(fid); - if ~usepipe - retcode = system(cmd); - if retcode !=0 - error('could not call imagemagick convert'); - end - unlink( tnam ); - end - -unwind_protect_cleanup -empty_list_elements_ok= save_empty_list_elements_ok; -warn_empty_list_elements= save_warn_empty_list_elements; -end_unwind_protect - -# -# $Log$ -# -# Patch 2008/03/25 20:42:00 Michal Fita -# Compability with ImageMagick on Windows -# -# Revision 1.3 2007/01/02 21:58:38 hauberg -# Documentation is now in Texinfo (looks better on the website) -# -# Revision 1.2 2006/11/26 10:47:39 hauberg -# Compatibility changes -# -# Revision 1.1 2006/08/20 12:59:34 hauberg -# Changed the structure to match the package system -# -# Revision 1.11 2006/03/22 17:50:47 qspencer -# Change calls to 'system' function to reflect new ordering of output arguments. -# -# Revision 1.10 2005/09/08 02:00:17 pkienzle -# [for Bill Denney] isstr -> ischar -# -# Revision 1.9 2005/07/21 16:03:02 aadler -# Improve error messages and use pipes -# -# Revision 1.8 2005/05/25 03:43:40 pkienzle -# Author/Copyright consistency -# -# Revision 1.7 2005/04/25 01:05:28 aadler -# added GPL copyrights -# -# Revision 1.6 2003/09/12 14:22:42 adb014 -# Changes to allow use with latest CVS of octave (do_fortran_indexing, etc) -# -# Revision 1.5 2003/07/25 19:11:41 pkienzle -# Make sure all files names referenced in system calls are wrapped in quotes -# to protect against spaces in the path. -# -# Revision 1.4 2002/11/27 08:40:11 pkienzle -# author/license updates -# -# Revision 1.3 2002/03/19 18:14:13 aadler -# unfortunately using popen seems to create problems, mostly -# on win32, but also on linux, so we need to move to a tmpfile approach -# -# Revision 1.2 2002/03/17 05:26:14 aadler -# now accept filenames with spaces -# -# Revision 1.1 2002/03/11 01:56:47 aadler -# general image read/write functionality using imagemagick utilities -# -# Modified: trunk/octave-forge/main/image/src/Makeconf.in =================================================================== --- trunk/octave-forge/main/image/src/Makeconf.in 2008-09-30 17:56:02 UTC (rev 5324) +++ trunk/octave-forge/main/image/src/Makeconf.in 2008-10-01 09:51:38 UTC (rev 5325) @@ -6,7 +6,6 @@ @DEFHAVE_JPEG@ @DEFHAVE_PNG@ -@DEFHAVE_MAGICKXX@ MKOCTFILE=@MKOCTFILE@ %.o: %.c ; $(MKOCTFILE) -c $< Deleted: trunk/octave-forge/main/image/src/__magick_read__.cc =================================================================== --- trunk/octave-forge/main/image/src/__magick_read__.cc 2008-09-30 17:56:02 UTC (rev 5324) +++ trunk/octave-forge/main/image/src/__magick_read__.cc 2008-10-01 09:51:38 UTC (rev 5325) @@ -1,314 +0,0 @@ -#include <octave/oct.h> -#include <Magick++.h> -#include <iostream> -using namespace std; -using namespace Magick; - -unsigned int scaleQuantumToDepth (const Quantum &_quantum, unsigned int depth) -{ - return (static_cast<unsigned int> (static_cast<double>(_quantum) / - QuantumRange * ((1 << depth) - 1))); -} - -octave_value_list read_indexed_images(vector<Image> imvec, Array<int> frameidx, bool wantalpha) -{ - octave_value_list output; - int rows = imvec[0].baseRows(); - int columns = imvec[0].baseColumns(); - int nframes = frameidx.length(); - ImageType type = imvec[0].type(); - - unsigned int mapsize = imvec[0].colorMapSize(); - int i = mapsize; - unsigned int depth = 0; - while(i >>= 1) depth++; - i = 0; - depth--; - while(depth >>= 1) i++; - depth = 1 << i; - - int x, y, frame; - const IndexPacket *pix; - switch(depth) { - case 1: - case 2: - case 4: - case 8: - { - uint8NDArray im = uint8NDArray(dim_vector(rows, columns, nframes)); - for(frame=0; frame < nframes; frame++) { - imvec[frameidx(frame)].getConstPixels(0,0, columns, rows); - pix = imvec[frameidx(frame)].getConstIndexes(); - i = 0; - for(y=0; y < rows; y++) { - for(x=0; x < columns; x++) { - im(y, x, frame) = static_cast<octave_uint8>(pix[i++]); - } - } - } - im.chop_trailing_singletons(); - output(0) = octave_value(im); - } - break; - case 16: - { - uint16NDArray im = uint16NDArray(dim_vector(rows, columns, nframes)); - for(frame=0; frame < nframes; frame++) { - imvec[frameidx(frame)].getConstPixels(0,0, columns, rows); - pix = imvec[frameidx(frame)].getConstIndexes(); - i = 0; - for(y=0; y < rows; y++) { - for(x=0; x < columns; x++) { - im(y, x, frame) = static_cast<octave_uint16>(pix[i++]); - } - } - } - im.chop_trailing_singletons(); - output(0) = octave_value(im); - } - break; - default: - error("Index depths bigger than 16-bit not supported"); - return octave_value_list(); - } - - ColorRGB c; - Matrix map = Matrix(mapsize, 3); - Matrix alpha; - switch(type) { - case PaletteMatteType: -/* warning("palettematte"); - map = Matrix(mapsize, 3); - alpha = Matrix(mapsize, 1); - for(i = 0; i < mapsize; i++) { - warning("%d", i); - c = imvec[0].colorMap(i); - map(i, 0) = c.red(); - map(i, 1) = c.green(); - map(i, 2) = c.blue(); - alpha(i, 1) = c.alpha(); - } - break; */ - case PaletteType: - alpha = Matrix(0,0); - for(i = 0; i < mapsize; i++) { - c = imvec[0].colorMap(i); - map(i, 0) = c.red(); - map(i, 1) = c.green(); - map(i, 2) = c.blue(); - } - break; - default: - error("Unsupported indexed image type"); - return octave_value_list(); - } - - output(1) = octave_value(map); - if(wantalpha) { - output(2) = octave_value(alpha); - } - return output; -} - -template <class T> -octave_value_list read_images(vector<Image> imvec, Array<int> frameidx, - unsigned int depth) -{ - int i; - T im; - int rows = imvec[0].baseRows(); - int columns = imvec[0].baseColumns(); - int nframes = frameidx.length(); - ImageType type = imvec[0].type(); - int x, y, frame; - const PixelPacket *pix; - dim_vector idim = dim_vector(); - idim.resize(4); - idim(0) = rows; - idim(1) = columns; - idim(2) = 1; - idim(3) = nframes; - Array<int> idx(dim_vector(4)); - switch(type) { - case BilevelType: - // break; - case GrayscaleType: - im = T(dim_vector(rows, columns, nframes)); - for(frame=0; frame < nframes; frame++) { - pix = imvec[frameidx(frame)].getConstPixels(0,0, columns, rows); - i = 0; - for(y=0; y < rows; y++) { - for(x=0; x < columns; x++) { - im(y, x, frame) = scaleQuantumToDepth (pix[i++].red, depth); - } - } - } - break; - case GrayscaleMatteType: - idim(2) = 2; - im = T(idim); - for(frame=0; frame < nframes; frame++) { - idx(3) = frame; - i = 0; - pix = imvec[frameidx(frame)].getConstPixels(0,0, columns, rows); - for(y=0; y < rows; y++) { - idx(0) = y; - for(x=0; x < columns; x++) { - idx(1) = x; - idx(2) = 0; - im(idx) = scaleQuantumToDepth (pix[i].red, depth); - idx(2) = 1; - im(idx) = scaleQuantumToDepth (pix[i].opacity, depth); - i++; - } - } - } - break; - case PaletteType: - case TrueColorType: - idim(2) = 3; - im = T(idim); - for(frame=0; frame < nframes; frame++) { - idx(3) = frame; - i = 0; - pix = imvec[frameidx(frame)].getConstPixels(0,0, columns, rows); - for(y=0; y < rows; y++) { - idx(0) = y; - for(x=0; x < columns; x++) { - idx(1) = x; - idx(2) = 0; - im(idx) = scaleQuantumToDepth (pix[i].red, depth); - idx(2) = 1; - im(idx) = scaleQuantumToDepth (pix[i].green, depth); - idx(2) = 2; - im(idx) = scaleQuantumToDepth (pix[i].blue, depth); - i++; - } - } - } - break; - case PaletteMatteType: - case TrueColorMatteType: - case ColorSeparationType: - idim(2) = 4; - im = T(idim); - for(frame=0; frame < nframes; frame++) { - idx(3) = frame; - i = 0; - pix = imvec[frameidx(frame)].getConstPixels(0,0, columns, rows); - for(y=0; y < rows; y++) { - idx(0) = y; - for(x=0; x < columns; x++) { - idx(1) = x; - idx(2) = 0; - im(idx) = scaleQuantumToDepth (pix[i].red, depth); - idx(2) = 1; - im(idx) = scaleQuantumToDepth (pix[i].green, depth); - idx(2) = 2; - im(idx) = scaleQuantumToDepth (pix[i].blue, depth); - idx(2) = 3; - im(idx) = scaleQuantumToDepth (pix[i].opacity, depth); - i++; - } - } - } - break; - default: - error("Undefined Imagemagick image type"); - return octave_value_list(); - } - - im.chop_trailing_singletons(); - return octave_value_list(octave_value(im)); -} - -// instantiate templates -template octave_value_list read_images<boolNDArray>(vector<Image>, Array<int>, - unsigned int depth); -template octave_value_list read_images<uint8NDArray>(vector<Image>, - Array<int>, - unsigned int depth); -template octave_value_list read_images<uint16NDArray>(vector<Image>, - Array<int>, - unsigned int depth); - -DEFUN_DLD(__magick_read__, args, nargout, "\ --*- texinfo -*-\n\ -@deftypefn {Function File} {@var{m} =} __imagemagick_read__(@var{fname}, @var{index})\n\ -@deftypefnx{Function File} {[@var{m}, @var{colormap}] =} __imagemagick_read__(@var{fname}, @var{index})\n\ -@deftypefnx{Function File} {[@var{m}, @var{colormap}, @var{alpha}] =} __imagemagick_read__(@var{fname}, @var{index})\n\ -Read images with ImageMagick++. In general you should not be using this function.\n\ -Instead you should use @code{imread}.\n\ -@seealso{imread}\n\ -@end deftypefn\n\ -") { - octave_value_list output; - int i; - if(args.length() > 2 || args.length() < 1 || !args(0).is_string() \ - || nargout > 3) { - print_usage (); - return octave_value_list(); - } - Array<int> frameidx; - if(args.length() == 2 && args(1).is_real_type()) { - frameidx = args(1).int_vector_value(); - } else { - frameidx = Array<int>(1); - frameidx(0) = 1; - } - - vector<Image> imvec; - try { - // Read a file into vector of image objects - readImages(&imvec, args(0).string_value()); - } - catch( Warning &warning_ ) { - warning("Magick++ warning: %s", warning_.what()); - } - catch( ErrorCoder &error_) { - warning("Magick++ coder error: %s", error_.what()); - } - catch( Exception &error_ ) { - error("Magick++ exception: %s", error_.what()); - imvec.clear(); - return octave_value_list(); - } - - int nframes = imvec.size(); - for(i = 0; i < frameidx.length(); i++) { - frameidx(i) = frameidx(i) - 1; - if(frameidx(i) >= nframes || frameidx(i) < 0) { - error("Invalid index vector"); - imvec.clear(); - return output; - } - } - - ClassType klass = imvec[0].classType(); - if(klass == PseudoClass && nargout > 1) { - output = read_indexed_images(imvec, frameidx, (nargout == 3)); - } else { - unsigned int depth = imvec[0].modulusDepth(); - i = 0; - while(depth >>= 1) i++; - depth = 1 << i; - - if (depth == 1) - output = read_images<boolNDArray>(imvec, frameidx, depth); - else if (depth > 1 && depth <= 8) - output = read_images<uint8NDArray>(imvec, frameidx, depth); - else if (depth > 8 && depth <= 16) - output = read_images<uint16NDArray>(imvec, frameidx, depth); - else - error("Image depths bigger than 16-bit not supported"); - - if(nargout > 1) { - output(1) = Matrix(0,0); - if(nargout > 2) - output(2) = Matrix(0,0); - } - } - imvec.clear(); - - return output; -} Modified: trunk/octave-forge/main/image/src/configure.base =================================================================== --- trunk/octave-forge/main/image/src/configure.base 2008-09-30 17:56:02 UTC (rev 5324) +++ trunk/octave-forge/main/image/src/configure.base 2008-10-01 09:51:38 UTC (rev 5325) @@ -61,13 +61,4 @@ IMAGESTATUS="$IMAGESTATUS, png.h not found" fi -AC_CHECK_PROG(HAVE_MAGICKXX, Magick++-config, yes) -if test $HAVE_MAGICKXX ; then - IMAGESTATUS="$IMAGESTATUS, ImageMagick++" - AC_SUBST(DEFHAVE_MAGICKXX) - DEFHAVE_MAGICKXX="HAVE_MAGICKXX=1" -else - IMAGESTATUS="$IMAGESTATUS, ImageMagick++ not found" -fi - CONFIGURE_OUTPUTS="Makeconf" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |