home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-07-13 | 50.4 KB | 1,325 lines |
- Newsgroups: comp.sources.x
- From: cristy@eplrx7.es.duPont.com (Cristy)
- Subject: v20i059: imagemagic - X11 image processing and display, Part03/38
- Message-ID: <1993Jul14.175250.701@sparky.sterling.com>
- X-Md4-Signature: 3bbefe01cad948b8d584f7ca521c4231
- Sender: chris@sparky.sterling.com (Chris Olson)
- Organization: Sterling Software
- Date: Wed, 14 Jul 1993 17:52:50 GMT
- Approved: chris@sterling.com
-
- Submitted-by: cristy@eplrx7.es.duPont.com (Cristy)
- Posting-number: Volume 20, Issue 59
- Archive-name: imagemagic/part03
- Environment: X11
- Supersedes: imagemagic: Volume 13, Issue 17-37
-
- #!/bin/sh
- # this is magick.03 (part 3 of ImageMagick)
- # do not concatenate these parts, unpack them in order with /bin/sh
- # file ImageMagick/utilities/mogrify.man continued
- #
- if test ! -r _shar_seq_.tmp; then
- echo 'Please unpack part 1 first!'
- exit 1
- fi
- (read Scheck
- if test "$Scheck" != 3; then
- echo Please unpack part "$Scheck" next!
- exit 1
- else
- exit 0
- fi
- ) < _shar_seq_.tmp || exit 1
- if test ! -f _shar_wnt_.tmp; then
- echo 'x - still skipping ImageMagick/utilities/mogrify.man'
- else
- echo 'x - continuing file ImageMagick/utilities/mogrify.man'
- sed 's/^X//' << 'SHAR_EOF' >> 'ImageMagick/utilities/mogrify.man' &&
- .TP 5
- .B "-rotate \fIdegrees\fP"
- apply Paeth image rotation to the image.
- X
- Empty triangles left over from rotating the image are filled with the
- color defined by the pixel at location (0,0). Refer to \fB-border\fP
- to choose a specific color.
- .TP 5
- .B "-scale \fI<width factor>x<height factor>\fP"
- preferred size factors of the image.
- X
- This option behaves like \fB-geometry\fP except the width and height values
- are relative instead of absolute. The image size is multiplied by the
- width and height factors to obtain the final image dimensions. If only
- one factor is specified, both the width and height factors assume the
- value.
- X
- Factors may be fractional. To increase the size of an image, use a
- scale factor greater than 1.0. To decrease an image's size, use a
- scale factor less than 1.0. Default is 1.0.
- .TP 5
- .B "-scene \fIvalue\fP"
- image scene number.
- .TP 5
- .B "-shear \fI<x degrees>x<y degrees>\fP"
- shear the image along the X or Y axis by a positive or negative shear angle.
- X
- Shearing slides one edge of an image along the X or Y axis, creating a
- parallelogram. An X direction shear slides an edge along the X axis,
- while a Y direction shear slides an edge along the Y axis. The amount
- of the shear is controlled by a shear angle. For X direction shears,
- \fIx degrees>\fP is measured relative to the Y axis, and similarly, for
- Y direction shears \fIy degrees\fP is measured relative to the X axis.
- X
- Empty triangles left over from shearing the image are filled with the
- color defined by the pixel at location (0,0). Refer to \fB-border\fP
- to choose a specific color.
- .TP 5
- .B "-treedepth \fIvalue\fP"
- Normally, this integer value is zero or one. A zero or one tells
- \fBmogrify\fP to choose a optimal tree depth for the color reduction
- algorithm.
- X
- An optimal depth generally allows the best representation of the source
- image with the fastest computational speed and the least amount of
- memory. However, the default depth is inappropriate for some images.
- To assure the best representation, try values between 2 and 8 for this
- parameter. Refer to \fBquantize(9)\fP for more details.
- X
- The \fB-colors\fP or \fB-monochrome\fP option is required for this option
- to take effect.
- .TP 5
- .B "-undercolor \fI<undercolor factor>x<black-generation factor>\fP"
- control undercolor removal and black generation on CMYK images.
- X
- This option enables you to perform undercolor removal and black
- generation on CMYK images-- images to be printed on a four-color
- printing system. You can control how much cyan, magenta, and yellow
- to remove from your image and how much black to add to it.
- The standard undercolor removal is \fB1.0x1.0\fP. You'll
- frequently get better results, though, if the percentage of black you
- add to your image is slightly higher than the percentage of C, M, and Y
- you remove from it. For example you might try \fB0.5x0.7\fP.
- .TP 5
- .B -verbose
- print detailed information about the image.
- X
- This information is printed: image scene number; image name; image
- size; the image class (\fIDirectClass\fP or \fIPseudoClass\fP); the total
- number of unique colors (if known); and the number of seconds to read and
- transform the image. Refer to \fBmiff(5)\fP for a description of
- the image class.
- X
- If \fB-colors\fP is also specified, the total unique colors in the image
- and color reduction error values are printed. Refer to \fBquantize(9)\fP
- for a description of these values.
- .PP
- Any option you specify on the command line remains in effect until it is
- explicitly changed by specifying the option again with a different effect.
- For example, to mogrify two images, the first with 32 colors and the
- second with only 16 colors, use:
- .PP
- X mogrify -colors 32 cockatoo.miff -colors 16 macaw.miff
- .PP
- Change \fI-\fP to \fI\+\fP in any option above to reverse its effect.
- For example, specify \fB\+compress\fP to store the binary image in an
- uncompressed format.
- .PP
- By default, the image format is determined by its magic number. To
- specify a particular image format, precede the filename with an image
- format name and a colon (i.e. ps:image) or specify the image type as
- the filename suffix (i.e. image.ps). See \fBconvert(1)\fP for a list
- of valid image formats.
- .PP
- Specify \fIfile\fP as \fI-\fP for standard input and output. If
- \fIfile\fP has the extension \fB.Z\fP or \fB.gz\fP, the file is
- uncompressed with \fBuncompress\fP or \fBgunzip\fP respectively and
- subsequently compressed using with \fBcompress\fP or \fBgzip\fP.
- .SH SEE ALSO
- .B
- display(1), animate(1), import(1), convert(1), quantize(9), miff(5), X(1), compress(1)
- .SH COPYRIGHT
- Copyright 1993 E. I. du Pont de Nemours & Company
- .PP
- Permission to use, copy, modify, distribute, and sell this software and
- its documentation for any purpose is hereby granted without fee,
- provided that the above copyright notice appear in all copies and that
- both that copyright notice and this permission notice appear in
- supporting documentation, and that the name of E. I. du Pont de Nemours
- & Company not be used in advertising or publicity pertaining to
- distribution of the software without specific, written prior
- permission. E. I. du Pont de Nemours & Company makes no representations
- about the suitability of this software for any purpose. It is provided
- "as is" without express or implied warranty.
- .PP
- E. I. du Pont de Nemours & Company disclaims all warranties with regard
- to this software, including all implied warranties of merchantability
- and fitness, in no event shall E. I. du Pont de Nemours & Company be
- liable for any special, indirect or consequential damages or any
- damages whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action, arising
- out of or in connection with the use or performance of this software.
- .SH ACKNOWLEDGEMENTS
- Michael Halle, Spatial Imaging Group at MIT, for the initial
- implementation of Alan Paeth's image rotation algorithm.
- .PP
- David Pensak, E. I. du Pont de Nemours & Company, for providing a
- computing environment that made this program possible.
- .PP
- Paul Raveling, USC Information Sciences Institute, for the original
- idea of using space subdivision for the color reduction algorithm.
- .SH AUTHORS
- John Cristy, E.I. du Pont de Nemours & Company Incorporated
- SHAR_EOF
- echo 'File ImageMagick/utilities/mogrify.man is complete' &&
- chmod 0644 ImageMagick/utilities/mogrify.man ||
- echo 'restore of ImageMagick/utilities/mogrify.man failed'
- Wc_c="`wc -c < 'ImageMagick/utilities/mogrify.man'`"
- test 13912 -eq "$Wc_c" ||
- echo 'ImageMagick/utilities/mogrify.man: original size 13912, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= ImageMagick/utilities/combine.c ==============
- if test -f 'ImageMagick/utilities/combine.c' -a X"$1" != X"-c"; then
- echo 'x - skipping ImageMagick/utilities/combine.c (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting ImageMagick/utilities/combine.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/utilities/combine.c' &&
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % %
- % %
- % %
- % CCCC OOO M M BBBB IIIII N N EEEEE %
- % C O O MM MM B B I NN N E %
- % C O O M M M BBBB I N N N EEE %
- % C O O M M B B I N NN E %
- % CCCC OOO M N BBBB IIIII N N EEEEE %
- % %
- % %
- % Digitally combine two images. %
- % %
- % %
- % %
- % Software Design %
- % John Cristy %
- % January 1993 %
- % %
- % %
- % Copyright 1993 E. I. Dupont de Nemours & Company %
- % %
- % Permission to use, copy, modify, distribute, and sell this software and %
- % its documentation for any purpose is hereby granted without fee, %
- % provided that the above Copyright notice appear in all copies and that %
- % both that Copyright notice and this permission notice appear in %
- % supporting documentation, and that the name of E. I. Dupont de Nemours %
- % & Company not be used in advertising or publicity pertaining to %
- % distribution of the software without specific, written prior %
- % permission. E. I. Dupont de Nemours & Company makes no representations %
- % about the suitability of this software for any purpose. It is provided %
- % "as is" without express or implied warranty. %
- % %
- % E. I. Dupont de Nemours & Company disclaims all warranties with regard %
- % to this software, including all implied warranties of merchantability %
- % and fitness, in no event shall E. I. Dupont de Nemours & Company be %
- % liable for any special, indirect or consequential damages or any %
- % damages whatsoever resulting from loss of use, data or profits, whether %
- % in an action of contract, negligence or other tortious action, arising %
- % out of or in connection with the use or performance of this software. %
- % %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- % The combine program syntax is:
- %
- % Usage: combine [options ...] input_file1 input_file2 output_file
- %
- % Where options include:
- % -alpha store alpha channel if the image has one
- % -colors value preferred number of colors in the image
- % -compose operator composite operator
- % -colorspace type GRAY, RGB, XYZ, YCbCr, YIQ, or YUV
- % -compress type RunlengthEncoded or QEncoded
- % -density geometry vertical and horizonal density of the image
- % -display server obtain image or font from this X server
- % -dither apply Floyd/Steinberg error diffusion to image
- % -font name X11 font for displaying text
- % -geometry geometry width and height of the image
- % -interlace type NONE, LINE, or PLANE
- % -page geometry size and location of the Postscript page
- % -quality value JPEG quality setting
- % -scene value image scene number
- % -stereo combine two images to form red-green stereo image
- % -treedepth value depth of the color classification tree
- % -verbose print detailed information about the image
- %
- % Change '-' to '+' in any option above to reverse its effect. For
- % example, specify +alpha to store the image without its alpha channel.
- %
- %
- */
- X
- #include "display.h"
- #include "image.h"
- #include "X.h"
- X
- /*
- X Global declarations.
- */
- char
- X *client_name;
- X
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % %
- % %
- % %
- % E r r o r %
- % %
- % %
- % %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- % Function Error displays an error message and then terminates the program.
- %
- % The format of the Error routine is:
- %
- % Error(message,qualifier)
- %
- % A description of each parameter follows:
- %
- % o message: Specifies the message to display before terminating the
- % program.
- %
- % o qualifier: Specifies any qualifier to the message.
- %
- %
- */
- void Error(message,qualifier)
- char
- X *message,
- X *qualifier;
- {
- X (void) fprintf(stderr,"%s: %s",client_name,message);
- X if (qualifier != (char *) NULL)
- X (void) fprintf(stderr," (%s)",qualifier);
- X (void) fprintf(stderr,".\n");
- X exit(1);
- }
- X
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % %
- % %
- % %
- % U s a g e %
- % %
- % %
- % %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- % Procedure Usage displays the program usage;
- %
- % The format of the Usage routine is:
- %
- % Usage()
- %
- %
- */
- static void Usage()
- {
- X char
- X **p;
- X
- X static char
- X *options[]=
- X {
- X "-alpha store alpha channel if the image has one",
- X "-colors value preferred number of colors in the image",
- X "-colorspace type GRAY, RGB, XYZ, YCbCr, YIQ, or YUV",
- X "-compose operator composite operator",
- X "-compress type RunlengthEncoded or QEncoded",
- X "-density geometry vertical and horizonal density of the image",
- X "-display server obtain image or font from this X server",
- X "-dither apply Floyd/Steinberg error diffusion to image",
- X "-font name X11 font for displaying text",
- X "-geometry geometry width and height of the image",
- X "-interlace type NONE, LINE, or PLANE",
- X "-page geometry size and location of the Postscript page",
- X "-quality value JPEG quality setting",
- X "-scene value image scene number",
- X "-stereo combine two images to form red-green stereo image",
- X "-treedepth value depth of the color classification tree",
- X "-verbose print detailed information about the image",
- X (char *) NULL
- X };
- X (void) fprintf(stderr,
- X "Usage: %s [options ...] input_file1 input_file2 output_file\n",
- X client_name);
- X (void) fprintf(stderr,"\nWhere options include:\n");
- X for (p=options; *p != (char *) NULL; p++)
- X (void) fprintf(stderr," %s\n",*p);
- X (void) fprintf(stderr,
- X "\nChange '-' to '+' in any option above to reverse its effect. For\n");
- X (void) fprintf(stderr,
- X "example, specify +alpha to store the image without an alpha channel.\n");
- X exit(1);
- }
- X
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % %
- % %
- % %
- % M a i n %
- % %
- % %
- % %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- %
- */
- int main(argc,argv)
- int
- X argc;
- X
- char
- X *argv[];
- {
- #define NotInitialized (unsigned int) (~0)
- X
- X char
- X *border_color,
- X *density,
- X *filename,
- X *font,
- X *image_geometry,
- X *option,
- X *page_geometry,
- X *server_name;
- X
- X double
- X normalized_maximum_error,
- X normalized_mean_error;
- X
- X Image
- X *alpha_image,
- X *beta_image,
- X *combined_image;
- X
- X ImageInfo
- X image_info;
- X
- X int
- X i,
- X status,
- X x;
- X
- X time_t
- X start_time;
- X
- X unsigned int
- X alpha,
- X colorspace,
- X compose,
- X compression,
- X dither,
- X interlace,
- X mean_error_per_pixel,
- X number_colors,
- X quality,
- X scene,
- X stereo,
- X tree_depth,
- X verbose;
- X
- X unsigned long
- X total_colors;
- X
- X /*
- X Initialize program variables.
- X */
- X client_name=argv[0];
- X if (argc < 4)
- X Usage();
- X /*
- X Read image and convert to MIFF format.
- X */
- X alpha=NotInitialized;
- X alpha_image=(Image *) NULL;
- X border_color=(char *) NULL;
- X beta_image=(Image *) NULL;
- X colorspace=RGBColorspace;
- X compose=OverCompositeOp;
- X compression=UndefinedCompression;
- X density=(char *) NULL;
- X dither=False;
- X font=(char *) NULL;
- X image_geometry=(char *) NULL;
- X interlace=NoneInterlace;
- X number_colors=0;
- X page_geometry=(char *) NULL;
- X quality=75;
- X scene=0;
- X server_name=(char *) NULL;
- X start_time=time((time_t *) NULL);
- X stereo=False;
- X tree_depth=0;
- X verbose=False;
- X /*
- X Check command syntax.
- X */
- X filename=(char *) NULL;
- X for (i=1; i < (argc-1); i++)
- X {
- X option=argv[i];
- X if (((int) strlen(option) < 2) || ((*option != '-') && (*option != '+')))
- X {
- X /*
- X Read input images.
- X */
- X filename=option;
- X GetImageInfo(&image_info);
- X (void) strcpy(image_info.filename,filename);
- X image_info.server_name=server_name;
- X image_info.font=font;
- X image_info.geometry=image_geometry;
- X image_info.page=page_geometry;
- X image_info.density=density;
- X image_info.border_color=border_color;
- X image_info.interlace=interlace;
- X image_info.quality=quality;
- X image_info.verbose=verbose;
- X if (alpha_image == (Image *) NULL)
- X {
- X alpha_image=ReadImage(&image_info);
- X if (alpha_image == (Image *) NULL)
- X exit(1);
- X continue;
- X }
- X if (beta_image != (Image *) NULL)
- X Error("input images already specified",filename);
- X beta_image=ReadImage(&image_info);
- X if (beta_image == (Image *) NULL)
- X exit(1);
- X }
- X else
- X switch(*(option+1))
- X {
- X case 'a':
- X {
- X alpha=(*option == '-');
- X break;
- X }
- X case 'b':
- X {
- X if (strncmp("bordercolor",option+1,7) == 0)
- X {
- X border_color=(char *) NULL;
- X if (*option == '-')
- X {
- X i++;
- X if (i == argc)
- X Error("missing color on -bordercolor",(char *) NULL);
- X border_color=argv[i];
- X }
- X break;
- X }
- X break;
- X }
- X case 'c':
- X {
- X if (strncmp("colors",option+1,7) == 0)
- X {
- X number_colors=0;
- X if (*option == '-')
- X {
- X i++;
- X if ((i == argc) || !sscanf(argv[i],"%d",&x))
- X Error("missing colors on -colors",(char *) NULL);
- X number_colors=atoi(argv[i]);
- X }
- X break;
- X }
- X if (strncmp("colorspace",option+1,7) == 0)
- X {
- X colorspace=RGBColorspace;
- X if (*option == '-')
- X {
- X i++;
- X if (i == argc)
- X Error("missing type on -colorspace",(char *) NULL);
- X option=argv[i];
- X colorspace=UndefinedColorspace;
- X if (Latin1Compare("gray",option) == 0)
- X colorspace=GRAYColorspace;
- X if (Latin1Compare("rgb",option) == 0)
- X colorspace=RGBColorspace;
- X if (Latin1Compare("xyz",option) == 0)
- X colorspace=XYZColorspace;
- X if (Latin1Compare("ycbcr",option) == 0)
- X colorspace=YCbCrColorspace;
- X if (Latin1Compare("yiq",option) == 0)
- X colorspace=YIQColorspace;
- X if (Latin1Compare("yuv",option) == 0)
- X colorspace=YUVColorspace;
- X if (colorspace == UndefinedColorspace)
- X Error("invalid colorspace type on -colorspace",option);
- X }
- X break;
- X }
- X if (strncmp("compose",option+1,5) == 0)
- X {
- X compose=ReplaceCompositeOp;
- X if (*option == '-')
- X {
- X i++;
- X if (i == argc)
- X Error("missing type on -compose",(char *) NULL);
- X option=argv[i];
- X compose=UndefinedCompositeOp;
- X if (Latin1Compare("over",option) == 0)
- X compose=OverCompositeOp;
- X if (Latin1Compare("in",option) == 0)
- X compose=InCompositeOp;
- X if (Latin1Compare("out",option) == 0)
- X compose=OutCompositeOp;
- X if (Latin1Compare("atop",option) == 0)
- X compose=AtopCompositeOp;
- X if (Latin1Compare("xor",option) == 0)
- X compose=XorCompositeOp;
- X if (Latin1Compare("plus",option) == 0)
- X compose=PlusCompositeOp;
- X if (Latin1Compare("minus",option) == 0)
- X compose=MinusCompositeOp;
- X if (Latin1Compare("add",option) == 0)
- X compose=AddCompositeOp;
- X if (Latin1Compare("subtract",option) == 0)
- X compose=SubtractCompositeOp;
- X if (Latin1Compare("difference",option) == 0)
- X compose=DifferenceCompositeOp;
- X if (Latin1Compare("replace",option) == 0)
- X compose=ReplaceCompositeOp;
- X if (compose == UndefinedCompositeOp)
- X Error("invalid compose type on -compose",option);
- X }
- X break;
- X }
- X if (strncmp("compress",option+1,3) == 0)
- X {
- X compression=NoCompression;
- X if (*option == '-')
- X {
- X i++;
- X if (i == argc)
- X Error("missing type on -compress",(char *) NULL);
- X option=argv[i];
- X if (Latin1Compare("runlengthencoded",option) == 0)
- X compression=RunlengthEncodedCompression;
- X else
- X if (Latin1Compare("qencoded",option) == 0)
- X compression=QEncodedCompression;
- X else
- X Error("invalid compression type on -compress",option);
- X }
- X break;
- X }
- X Error("unrecognized option",option);
- X break;
- X }
- X case 'd':
- X {
- X if (strncmp("density",option+1,3) == 0)
- X {
- X density=(char *) NULL;
- X if (*option == '-')
- X {
- X i++;
- X if (i == argc)
- X Error("missing geometry on -density",(char *) NULL);
- X density=argv[i];
- X }
- X break;
- X }
- X if (strncmp("display",option+1,3) == 0)
- X {
- X server_name=(char *) NULL;
- X if (*option == '-')
- X {
- X i++;
- X if (i == argc)
- X Error("missing server name on -display",(char *) NULL);
- X server_name=argv[i];
- X }
- X break;
- X }
- X if (strncmp("dither",option+1,3) == 0)
- X {
- X dither=(*option == '-');
- X break;
- X }
- X Error("unrecognized option",option);
- X break;
- X }
- X case 'f':
- X {
- X font=(char *) NULL;
- X if (*option == '-')
- X {
- X i++;
- X if (i == argc)
- X Error("missing font name on -font",(char *) NULL);
- X font=argv[i];
- X }
- X break;
- X }
- X case 'g':
- X {
- X image_geometry=(char *) NULL;
- X if (*option == '-')
- X {
- X i++;
- X if (i == argc)
- X Error("missing geometry on -geometry",(char *) NULL);
- X image_geometry=argv[i];
- X }
- X break;
- X }
- X case 'h':
- X {
- X Usage();
- X break;
- X }
- X case 'i':
- X {
- X if (strncmp("interlace",option+1,3) == 0)
- X {
- X interlace=NoneInterlace;
- X if (*option == '-')
- X {
- X i++;
- X if (i == argc)
- X Error("missing type on -interlace",(char *) NULL);
- X option=argv[i];
- X interlace=UndefinedInterlace;
- X if (Latin1Compare("none",option) == 0)
- X interlace=NoneInterlace;
- X if (Latin1Compare("line",option) == 0)
- X interlace=LineInterlace;
- X if (Latin1Compare("plane",option) == 0)
- X interlace=PlaneInterlace;
- X if (interlace == UndefinedInterlace)
- X Error("invalid interlace type on -interlace",option);
- X }
- X break;
- X }
- X Error("unrecognized option",option);
- X break;
- X }
- X case 'p':
- X {
- X if (strncmp("page",option+1,2) == 0)
- X {
- X page_geometry=(char *) NULL;
- X if (*option == '-')
- X {
- X i++;
- X if (i == argc)
- X Error("missing page geometry on -page",(char *) NULL);
- X page_geometry=argv[i];
- X }
- X break;
- X }
- X Error("unrecognized option",option);
- X break;
- X }
- X case 'q':
- X {
- X i++;
- X if ((i == argc) || !sscanf(argv[i],"%d",&x))
- X Error("missing quality on -quality",(char *) NULL);
- X quality=atoi(argv[i]);
- X break;
- X }
- X case 's':
- X {
- X if (strncmp("scene",option+1,2) == 0)
- X {
- X scene=0;
- X if (*option == '-')
- X {
- X i++;
- X if ((i == argc) || !sscanf(argv[i],"%d",&x))
- X Error("missing scene number on -scene",(char *) NULL);
- X scene=atoi(argv[i]);
- X }
- X break;
- X }
- X if (strncmp("stereo",option+1,2) == 0)
- X {
- X stereo=(*option == '-');
- X break;
- X }
- X Error("unrecognized option",option);
- X break;
- X }
- X case 't':
- X {
- X tree_depth=0;
- X if (*option == '-')
- X {
- X i++;
- X if ((i == argc) || !sscanf(argv[i],"%d",&x))
- X Error("missing depth on -treedepth",(char *) NULL);
- X tree_depth=atoi(argv[i]);
- X }
- X break;
- X }
- X case 'v':
- X {
- X verbose=(*option == '-');
- X break;
- X }
- X default:
- X {
- X Error("unrecognized option",option);
- X break;
- X }
- X }
- X }
- X if ((alpha_image == (Image *) NULL) || (beta_image == (Image *) NULL))
- X Usage();
- X /*
- X Combine image.
- X */
- X if (stereo)
- X combined_image=StereoImage(alpha_image,beta_image);
- X else
- X {
- X int
- X x_offset,
- X y_offset;
- X
- X unsigned int
- X size;
- X
- X /*
- X Digitally composite image.
- X */
- X x_offset=0;
- X y_offset=0;
- X if (image_info.geometry != (char *) NULL)
- X (void) XParseGeometry(image_info.geometry,&x_offset,&y_offset,&size,
- X &size);
- X CompositeImage(beta_image,compose,alpha_image,x_offset,y_offset);
- X combined_image=beta_image;
- X }
- X if (combined_image == (Image *) NULL)
- X exit(1);
- X /*
- X Write image.
- X */
- X total_colors=0;
- X if (alpha != NotInitialized)
- X combined_image->alpha=alpha;
- X if (compression != UndefinedCompression)
- X combined_image->compression=compression;
- X if (scene != 0)
- X combined_image->scene=scene;
- X (void) strcpy(combined_image->filename,argv[i]);
- X if (colorspace == GRAYColorspace)
- X QuantizeImage(combined_image,256,8,dither,GRAYColorspace,True);
- X if (number_colors != 0)
- X if ((combined_image->class == DirectClass) ||
- X (combined_image->colors > number_colors))
- X {
- X /*
- X Reduce the number of colors in the image.
- X */
- X QuantizeImage(combined_image,number_colors,tree_depth,dither,colorspace,
- X True);
- X if (verbose)
- X {
- X /*
- X Measure quantization error.
- X */
- X QuantizationError(combined_image,&mean_error_per_pixel,
- X &normalized_mean_error,&normalized_maximum_error);
- X total_colors=NumberColors(combined_image,(FILE *) NULL);
- X }
- X SyncImage(combined_image);
- X }
- X status=WriteImage(&image_info,combined_image);
- X if (verbose)
- X {
- X /*
- X Display detailed info about the image.
- X */
- X (void) fprintf(stderr,"[%u] %s %s=>%s %ux%u",combined_image->scene,
- X alpha_image->filename,filename,combined_image->filename,
- X combined_image->columns,combined_image->rows);
- X if (combined_image->class == DirectClass)
- X (void) fprintf(stderr," DirectClass");
- X else
- X if (total_colors == 0)
- X (void) fprintf(stderr," PseudoClass %uc",combined_image->colors);
- X else
- X {
- X (void) fprintf(stderr," PseudoClass %lu=>%uc",total_colors,
- X combined_image->colors);
- X (void) fprintf(stderr," %u/%.6f/%.6fe",mean_error_per_pixel,
- X normalized_mean_error,normalized_maximum_error);
- X }
- X (void) fprintf(stderr," %s %lds\n",combined_image->magick,
- X time((time_t *) NULL)-start_time+1);
- X }
- X return(!status);
- }
- SHAR_EOF
- chmod 0644 ImageMagick/utilities/combine.c ||
- echo 'restore of ImageMagick/utilities/combine.c failed'
- Wc_c="`wc -c < 'ImageMagick/utilities/combine.c'`"
- test 23690 -eq "$Wc_c" ||
- echo 'ImageMagick/utilities/combine.c: original size 23690, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= ImageMagick/utilities/combine.man ==============
- if test -f 'ImageMagick/utilities/combine.man' -a X"$1" != X"-c"; then
- echo 'x - skipping ImageMagick/utilities/combine.man (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting ImageMagick/utilities/combine.man (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/utilities/combine.man' &&
- .ad l
- .nh
- .TH combine 1 "10 January 1993" "ImageMagick"
- .SH NAME
- combine - combine images to create new images.
- .SH SYNOPSIS
- .B "combine"
- [ \fIoptions\fP ... ] \fIinput_file1\fP \fIinput_file2\fP \fIoutput_file\fP
- .SH DESCRIPTION
- \fBcombine\fP combine images to create new images.
- .SH EXAMPLES
- .PP
- To combine a image of a cockatoo with a perch, use
- .PP
- .B
- X combine cockatoo.miff perch.ras composite.miff
- .PP
- To compute the difference between images in a series, use
- .PP
- .B
- X combine -compose difference series.1 series.2 difference.miff
- .PP
- To combine a image of a cockatoo with a perch starting at location (100,150),
- use
- .PP
- .B
- X combine -geometry +100+150 cockatoo.miff perch.ras composite.miff
- .SH OPTIONS
- .TP 5
- .B "-alpha"
- store alpha channel if the image has one.
- .TP 5
- .B "-colors \fIvalue\fP"
- preferred number of colors in the image.
- X
- The actual number of colors in the image may be less than your request,
- but never more. Note, this is a color reduction option. Images with
- less unique colors than specified with this option will remain unchanged.
- Refer to \fBquantize(9)\fP for more details.
- X
- Note, options \fB-dither\fP, \fB-colorspace\fP, and \fB-treedepth\fP affect
- the color reduction algorithm.
- .TP 5
- .B "-colorspace \fIvalue\fP"
- the type of colorspace: \fBGRAY\fP, \fBRGB\fP, \fBXYZ\fP, \fBYCbCr\fP,
- \fBYIQ\fP, or \fBYUV\fP.
- X
- Color reduction, by default, takes place in the RGB color space.
- Empirical evidence suggests that distances in color spaces such as YUV
- or YIQ correspond to perceptual color differences more closely
- than do distances in RGB space. These color spaces may give better
- results when color reducing an image. Refer to \fBquantize(9)\fP for
- more details.
- X
- The \fB-colors\fP or \fB-monochrome\fP option is required for this option
- to take effect.
- .TP 5
- .B "-compose \fIoperator\fP"
- the type of image composition.
- X
- By default, each of the composite image pixels are replaced by the
- cooresponding image tile pixel. You can choose an alternate composite
- operation:
- X
- X over
- X in
- X out
- X atop
- X xor
- X plus
- X minus
- X add
- X subtract
- X difference
- X replace
- .PP
- The operations behaves as follows:
- .TP 9
- .B over
- The result will be the union of the two image shapes, with \fIimage\fP
- obscuring \fIcomposite image\fP in the region of overlap.
- .TP 9
- .B in
- The result is simply \fIimage\fP cut by the shape of \fIcomposite
- image\fP. None of the image data of \fIcomposite image\fP will be in the
- result.
- .TP 9
- .B out
- The resulting image is \fIimage\fP with the shape of \fIcomposite image\fP
- cut out.
- .TP 9
- .B atop
- The result is the same shape as image \fIcomposite image\fP, with
- \fIimage\fP obscuring \fIcomposite image\fP where the image shapes
- overlap. Note this differs from \fBover\fP because the portion of
- \fIimage\fP outside \fIcomposite image\fP's shape does not appear in the
- result.
- .TP 9
- .B xor
- The result is the image data from both \fIimage\fP and \fIcomposite image\fP
- that is outside the overlap region. The overlap region will be blank.
- .TP 9
- .B plus
- The result is just the sum of the image data. Output values are
- clipped to 255 (no overflow). This operation is independent
- of the alpha channels.
- .TP 9
- .B minus
- The result of \fIimage\fP \- \fIcomposite image\fP, with underflow clipped
- to zero. The alpha channel is ignored (set to 255, full coverage).
- .TP 9
- .B add
- The result of \fIimage\fP + \fIcomposite image\fP, with overflow wrapping
- around (\fImod\fP 256).
- .TP 9
- .B subtract
- The result of \fIimage\fP - \fIcomposite image\fP, with underflow wrapping
- around (\fImod\fP 256). The \fBadd\fP and \fBsubtract\fP operators can
- be used to perform reversible transformations.
- .TP 9
- .B difference
- The result of abs(\fIimage\fP \- \fIcomposite image\fP). This is useful
- for comparing two very similar images.
- .TP 9
- .B replace
- The resulting image is \fIcomposite image\fP replaced with \fIimage\fP.
- Here the alpha information is ignored.
- X
- .TP 5
- The image compositor requires an alpha, or matte channel in the image
- for some operations. This extra channel usually defines a mask which
- represents a sort of a cookie-cutter for the image. This is the case
- when alpha is 255 (full coverage) for pixels inside the shape, zero
- outside, and between zero and 255 on the boundary. If \fIimage\fP does
- not have an alpha channel, it is initialized with 0 for any pixel
- matching in color to pixel location (0,0), otherwise 255 (to work
- properly \fBborderwidth\fP must be 0).
- .TP 5
- .B "-compress \fItype\fP"
- the type of image compression: \fIQEncoded\fP or \fIRunlengthEncoded\fP.
- X
- Specify \fB\+compress\fP to store the binary image in an uncompressed format.
- The default is the compression type of the specified image file.
- .TP 5
- .B "-density \fI<width>x<height>
- vertical and horizonal density of the image.
- X
- This option specifies an image density whose interpretation changes
- with the type of image. The default is 72 dots per inch in the
- horizonal and vertical direction for Postscript. Text files default to
- 80 characters in width and 60 lines in height. Use this option to
- alter the default density.
- .TP 5
- .B "-display \fIhost:display[.screen]\fP"
- specifies the X server to contact; see \fBX(1)\fP.
- .TP 5
- .B "-dither"
- apply Floyd/Steinberg error diffusion to the image.
- X
- The basic strategy of dithering is to trade intensity resolution for
- spatial resolution by averaging the intensities of several neighboring
- pixels. Images which suffer from severe contouring when reducing colors
- can be improved with this option.
- X
- The \fB-colors\fP option is required for dithering to take effect.
- .TP 5
- .B "-font \fIname\fP"
- This option specifies the font to be used for displaying normal text.
- The default is \fBfixed\fP.
- .TP 5
- .B "-geometry \fI<width>x<height>{\+-}<x offset>{\+-}<y offset>\fP"
- the width and height of the image.
- X
- Use this option to specified the width and height of raw images whose
- dimensions are unknown such as \fBGRAY\fP, \fBRGB\fP, and \fBCMYK\fP.
- This option can also change the default 8.5 by 11 width and height of
- the Postscript canvas.
- X
- By default the images are combined relative to the top left corner,
- location (0,0). Use \fI<x offset>\fP and \fI<y offset>\fP to specify
- a particular location to combine the images.
- .TP 5
- .B "-interlace \fItype\fP"
- the type of interlacing scheme: \fBNONE\fP, \fBLINE\fP, or \fBPLANE\fP.
- X
- This option is used to specify the type of interlacing scheme for raw
- image formats such as \fBRGB\fP or \fBYUV\fP. \fBNONE\fP means do not
- interlace (RGBRGBRGBRGBRGBRGB...), \fBLINE\fP uses scanline
- interlacing (RRR...GGG...BBB...RRR...GGG...BBB...), and \fBPLANE\fP uses
- plane interlacing (RRRRRR...GGGGGG...BBBBBB...).
- .TP 5
- .B "-page \fI<width>x<height>{\+-}<x offset>{\+-}<y offset>\fP"
- preferred size and location of the Postscript page.
- X
- Use this option to specify the dimensions of the Postscript page in picas. The
- default is to center the image on a letter page, 612 by 792 picas.
- Other common sizes are:
- X
- X 540x720 Note
- X 612x1008 Legal
- X 842x1190 A3
- X 595x842 A4
- X 421x595 A5
- X 297x421 A6
- X 709x1002 B4
- X 612x936 U.S. Foolscap
- X 612x936 European Foolscap
- X 396x612 Half Letter
- X 792x1224 11x17
- X 1224x792 Ledger
- X
- The page geometry is relative to the vertical and horizonal density of the
- Postscript page. See \fB-density\fP for details.
- .TP 5
- .B "-quality \fIvalue\fP"
- JPEG quality setting.
- X
- Quality is 0 (worst) to 100 (best). The default is 75.
- .TP 5
- .B "-scene \fIvalue\fP"
- image scene number.
- .TP 5
- .B "-stereo"
- combine two images into a red-green stereo image.
- X
- The left side of the stereo pair is saved as the red channel of the output
- image. The right sife is saved as the green channel. Red-blue stereo
- glasses are required to properly view the stereo image.
- .TP 5
- .B "-treedepth \fIvalue\fP"
- Normally, this integer value is zero or one. A zero or one tells
- \fBcombine\fP to choose a optimal tree depth for the color reduction
- algorithm.
- X
- An optimal depth generally allows the best representation of the source
- image with the fastest computational speed and the least amount of
- memory. However, the default depth is inappropriate for some images.
- To assure the best representation, try values between 2 and 8 for this
- parameter. Refer to \fBquantize(9)\fP for more details.
- X
- The \fB-colors\fP option is required for this option to take effect.
- .TP 5
- .B -verbose
- print detailed information about the image.
- X
- This information is printed: image scene number; image name; combined
- image name; image size; the image class (\fIDirectClass\fP or
- \fIPseudoClass\fP); the total number of unique colors; and the number
- of seconds to read and combine the image.
- .PP
- Change '-' to '+' in any option above to reverse its effect. For
- example, specify +alpha to store the image without its alpha channel.
- .PP
- By default, the image format is determined by its magic number. To
- specify a particular image format, precede the filename with an image
- format name and a colon (i.e. ps:image) or specify the image type as
- the filename suffix (i.e. image.ps). See \fBconvert(1)\fP for a list
- of valid image formats.
- .PP
- When you specify \fBX\fP as your image type, the filename has special
- meaning. It specifies an X window by id, name, or \fBroot\fP. If no
- filename is specified, the window is selected by clicking the mouse in
- the desired window.
- .PP
- Specify \fIinput_file\fP as \fI-\fP for standard input,
- \fIoutput_file\fP as \fI-\fP for standard output. If \fIinput_file\fP
- has the extension \fB.Z\fP or \fB.gz\fP, the file is uncompressed with
- \fBuncompress\fP or \fBgunzip\fP respectively. If \fIoutput_file\fP
- has the extension \fB.Z\fP or \fB.gz\fP, the file size is compressed
- using with \fBcompress\fP or \fBgzip\fP respectively. If
- \fIoutput_file\fP already exists, you will be prompted as to whether it
- should be overwritten.
- .SH ENVIRONMENT
- .PP
- .TP 5
- .B display
- To get the default host, display number, and screen.
- .SH SEE ALSO
- .B
- display(1), animate(1), mogrify(1), quantize(9), X(1), miff(5)
- .SH COPYRIGHT
- Copyright 1993 E. I. du Pont de Nemours & Company
- .PP
- Permission to use, copy, modify, distribute, and sell this software and
- its documentation for any purpose is hereby granted without fee,
- provided that the above copyright notice appear in all copies and that
- both that copyright notice and this permission notice appear in
- supporting documentation, and that the name of E. I. du Pont de Nemours
- & Company not be used in advertising or publicity pertaining to
- distribution of the software without specific, written prior
- permission. E. I. du Pont de Nemours & Company makes no representations
- about the suitability of this software for any purpose. It is provided
- "as is" without express or implied warranty.
- .PP
- E. I. du Pont de Nemours & Company disclaims all warranties with regard
- to this software, including all implied warranties of merchantability
- and fitness, in no event shall E. I. du Pont de Nemours & Company be
- liable for any special, indirect or consequential damages or any
- damages whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action, arising
- out of or in connection with the use or performance of this software.
- .SH AUTHORS
- John Cristy, E.I. du Pont De Nemours & Company Incorporated
- SHAR_EOF
- chmod 0644 ImageMagick/utilities/combine.man ||
- echo 'restore of ImageMagick/utilities/combine.man failed'
- Wc_c="`wc -c < 'ImageMagick/utilities/combine.man'`"
- test 11289 -eq "$Wc_c" ||
- echo 'ImageMagick/utilities/combine.man: original size 11289, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= ImageMagick/utilities/segment.c ==============
- if test -f 'ImageMagick/utilities/segment.c' -a X"$1" != X"-c"; then
- echo 'x - skipping ImageMagick/utilities/segment.c (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting ImageMagick/utilities/segment.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/utilities/segment.c' &&
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % %
- % %
- % %
- % SSSSS EEEEE GGGG M M EEEEE N N TTTTT %
- % SS E G MM MM E NN N T %
- % SSS EEE G GGG M M M EEE N N N T %
- % SS E G G M M E N NN T %
- % SSSSS EEEEE GGGG M M EEEEE N N T %
- % %
- % %
- % Segment an Image with Thresholding and the Fuzzy c-Means Technique. %
- % %
- % %
- % %
- % Software Design %
- % John Cristy %
- % April 1993 %
- % %
- % %
- % Copyright 1993 E. I. Dupont de Nemours & Company %
- % %
- % Permission to use, copy, modify, distribute, and sell this software and %
- % its documentation for any purpose is hereby granted without fee, %
- % provided that the above Copyright notice appear in all copies and that %
- % both that Copyright notice and this permission notice appear in %
- % supporting documentation, and that the name of E. I. Dupont de Nemours %
- % & Company not be used in advertising or publicity pertaining to %
- % distribution of the software without specific, written prior %
- % permission. E. I. Dupont de Nemours & Company makes no representations %
- % about the suitability of this software for any purpose. It is provided %
- % "as is" without express or implied warranty. %
- % %
- % E. I. Dupont de Nemours & Company disclaims all warranties with regard %
- % to this software, including all implied warranties of merchantability %
- % and fitness, in no event shall E. I. Dupont de Nemours & Company be %
- % liable for any special, indirect or consequential damages or any %
- % damages whatsoever resulting from loss of use, data or profits, whether %
- % in an action of contract, negligence or other tortious action, arising %
- % out of or in connection with the use or performance of this software. %
- % %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- % Segment segments an image by analyzing the histograms of the color
- % components and identifying units that are homogeneous with the fuzzy
- % c-means technique. The scale-space filter analyzes the histograms of
- % the three color components of the image and identifies a set of classes.
- % The extents of each class is used to coarsely segment the image with
- % thresholding. The color associated with each class is determined by
- % the mean color of all pixels within the extents of a particular class.
- % Finally, any unclassified pixels are assigned to the closest class with
- % the fuzzy c-means technique.
- %
- % The fuzzy c-Means algorithm can be summarized as follows:
- %
- % o Build a histogram, one for each color component of the image.
- %
- % o For each histogram, successively apply the scale-space
- % filter and build an interval tree of zero crossings in
- % the second derivative at each scale. Analyze this
- % scale-space ``fingerprint'' to determine which peaks and
- % valleys in the histogram are most predominant.
- %
- % o The fingerprint defines intervals on the axis of the
- % histogram. Each interval contains either a minima or a
- % maxima in the original signal. If each color component
- % lies within the maxima interval, that pixel is considered
- % ``classified'' and is assigned an unique class number.
- %
- % o Any pixel that fails to be classified in the above
- % thresholding pass is classified using the fuzzy
- % c-Means technique. It is assigned to one of the classes
- % discovered in the histogram analysis phase.
- %
- % The fuzzy c-Means technique attempts to cluster a pixel by finding
- % the local minima of the generalized within group sum of squared error
- % objective function. A pixel is assigned to the closest class of which
- % the fuzzy membership has a maximum value.
- %
- % Segment is strongly based on software written by Andy Gallo, University
- % of Delaware.
- %
- % The following reference was used in creating this program:
- %
- % Young Won Lim, Sang Uk Lee, "On The Color Image Segmentation Algorithm
- % Based on the Thresholding and the Fuzzy c-Means Techniques", Pattern
- % Recognition, Volume 23, Number 9, pages 935-952, 1990.
- %
- % The segment program syntax is:
- %
- % Usage: segment [options ...] input_file output_file
- %
- % Where options include:
- % -alpha store alpha channel if the image has one
- % -colorspace type GRAY, RGB, XYZ, YCbCr, YIQ, or YUV
- % -compress type RunlengthEncoded or QEncoded
- % -density geometry vertical and horizonal density of the image
- SHAR_EOF
- true || echo 'restore of ImageMagick/utilities/segment.c failed'
- fi
- echo 'End of ImageMagick part 3'
- echo 'File ImageMagick/utilities/segment.c is continued in part 4'
- echo 4 > _shar_seq_.tmp
- exit 0
-
- exit 0 # Just in case...
- --
- // chris@Sterling.COM | Send comp.sources.x submissions to:
- \X/ Amiga - The only way to fly! | sources-x@sterling.com
- "It's intuitively obvious to the |
- most casual observer..." | GCS d+/-- p+ c++ l+ m+ s++/+ g+ w+ t+ r+ x+
-