diff --git a/src/modules/Image/doc/Image.html b/src/modules/Image/doc/Image.html index 06d658ed94717ed070bd70ab7788bc3331514568..70e8ba992f587f77671f0f7330d24a74115f3d31 100644 --- a/src/modules/Image/doc/Image.html +++ b/src/modules/Image/doc/Image.html @@ -10,23 +10,23 @@ This module adds image-drawing and -manipulating <h4>NOTE</h4> <blockquote> -$Id: Image.html,v 1.4 1997/05/29 19:38:25 mirar Exp $<br> - $Id: Image.html,v 1.4 1997/05/29 19:38:25 mirar Exp $<br> - $Id: Image.html,v 1.4 1997/05/29 19:38:25 mirar Exp $<br> - $Id: Image.html,v 1.4 1997/05/29 19:38:25 mirar Exp $<br> - $Id: Image.html,v 1.4 1997/05/29 19:38:25 mirar Exp $<br> - $Id: Image.html,v 1.4 1997/05/29 19:38:25 mirar Exp $<br> - -<p> $Id: Image.html,v 1.4 1997/05/29 19:38:25 mirar Exp $<br> - $Id: Image.html,v 1.4 1997/05/29 19:38:25 mirar Exp $<br> - $Id: Image.html,v 1.4 1997/05/29 19:38:25 mirar Exp $<br> - $Id: Image.html,v 1.4 1997/05/29 19:38:25 mirar Exp $<br> - $Id: Image.html,v 1.4 1997/05/29 19:38:25 mirar Exp $<br> - $Id: Image.html,v 1.4 1997/05/29 19:38:25 mirar Exp $<br> - $Id: Image.html,v 1.4 1997/05/29 19:38:25 mirar Exp $<br> - $Id: Image.html,v 1.4 1997/05/29 19:38:25 mirar Exp $<br> - $Id: Image.html,v 1.4 1997/05/29 19:38:25 mirar Exp $<br> - $Id: Image.html,v 1.4 1997/05/29 19:38:25 mirar Exp $<br> +$Id: Image.html,v 1.5 1997/05/29 22:45:15 mirar Exp $<br> + $Id: Image.html,v 1.5 1997/05/29 22:45:15 mirar Exp $<br> + $Id: Image.html,v 1.5 1997/05/29 22:45:15 mirar Exp $<br> + $Id: Image.html,v 1.5 1997/05/29 22:45:15 mirar Exp $<br> + $Id: Image.html,v 1.5 1997/05/29 22:45:15 mirar Exp $<br> + $Id: Image.html,v 1.5 1997/05/29 22:45:15 mirar Exp $<br> + +<p> $Id: Image.html,v 1.5 1997/05/29 22:45:15 mirar Exp $<br> + $Id: Image.html,v 1.5 1997/05/29 22:45:15 mirar Exp $<br> + $Id: Image.html,v 1.5 1997/05/29 22:45:15 mirar Exp $<br> + $Id: Image.html,v 1.5 1997/05/29 22:45:15 mirar Exp $<br> + $Id: Image.html,v 1.5 1997/05/29 22:45:15 mirar Exp $<br> + $Id: Image.html,v 1.5 1997/05/29 22:45:15 mirar Exp $<br> + $Id: Image.html,v 1.5 1997/05/29 22:45:15 mirar Exp $<br> + $Id: Image.html,v 1.5 1997/05/29 22:45:15 mirar Exp $<br> + $Id: Image.html,v 1.5 1997/05/29 22:45:15 mirar Exp $<br> + $Id: Image.html,v 1.5 1997/05/29 22:45:15 mirar Exp $<br> </blockquote> diff --git a/src/modules/Image/doc/Image.image.html b/src/modules/Image/doc/Image.image.html index 77b240301a90260f8ff65bd6713b23d071d91572..79dd823e0e04c7f966327ab9b1eff6312baa743b 100644 --- a/src/modules/Image/doc/Image.image.html +++ b/src/modules/Image/doc/Image.image.html @@ -35,14 +35,14 @@ The main object of the <tt><a href=Image.html>Image</a></tt> module, this object <tt><a href=Image.image.html#paste_mask>paste_mask</a></tt> <p> getting subimages, scaling, rotating: <tt><a href=Image.image.html#autocrop>autocrop</a></tt>, - <tt><a href=Image.image.html#ccw>ccw</a></tt>, - <tt><a href=Image.image.html#cw>cw</a></tt>, <tt><a href=Image.image.html#clone>clone</a></tt>, <tt><a href=Image.image.html#copy>copy</a></tt>, <tt><a href=Image.image.html#dct>dct</a></tt>, <tt><a href=Image.image.html#mirrorx>mirrorx</a></tt>, <tt><a href=Image.image.html#rotate>rotate</a></tt>, <tt><a href=Image.image.html#rotate_expand>rotate_expand</a></tt>, + <tt><a href=Image.image.html#rotate_ccw>rotate_ccw</a></tt>, + <tt><a href=Image.image.html#rotate_cw>rotate_cw</a></tt>, <tt><a href=Image.image.html#scale>scale</a></tt>, <tt><a href=Image.image.html#skewx>skewx</a></tt>, <tt><a href=Image.image.html#skewx_expand>skewx_expand</a></tt>, @@ -57,10 +57,11 @@ The main object of the <tt><a href=Image.html>Image</a></tt> module, this object <tt><a href=Image.image.html#invert>invert</a></tt>, <tt><a href=Image.image.html#map_closest>map_closest</a></tt>, <tt><a href=Image.image.html#map_fast>map_fast</a></tt>, + <tt><a href=Image.image.html#select_colors>select_colors</a></tt>, <tt><a href=Image.image.html#modify_by_intensity>modify_by_intensity</a></tt>, - <tt><a href=Image.image.html#select_from>select_from</a></tt> - <tt><a href=Image.image.html#rgb_to_hsv>rgb_to_hsv</a></tt> - <tt><a href=Image.image.html#hsv_to_rgb>hsv_to_rgb</a></tt> + <tt><a href=Image.image.html#select_from>select_from</a></tt>, + <tt><a href=Image.image.html#rgb_to_hsv>rgb_to_hsv</a></tt>, + <tt><a href=Image.image.html#hsv_to_rgb>hsv_to_rgb</a></tt> <p> converting to other datatypes: <tt><a href=Image.image.html#cast>cast</a></tt>, <tt><a href=Image.image.html#fromgif>fromgif</a></tt>, @@ -405,42 +406,68 @@ Applies a pixel-transform matrix, or filter, to the image. 1/k is sum of matrix, or sum of matrix multiplied with div. base is given by r,g,b and is normally black. -<p> blur (ie a 2d gauss function): +<p> <table><tr><td rowspan=2> + blur (ie a 2d gauss function): <pre> ({({1,2,1}), ({2,5,2}), ({1,2,1})}) </pre> + </td><td> + <img src=illustration_0.gif width=67 height=67> + </td><td> + <img src=lena.gif width=67 height=67> + </td> + <tr><td></td><td>original</td> + <tr><td> sharpen (k>8, preferably 12 or 16): <pre> ({({-1,-1,-1}), ({-1, k,-1}), ({-1,-1,-1})}) </pre> + </td><td> + <img src=illustration_2.gif width=67 height=67> + </td> -<p> edge detect: +<p> <tr><td> + edge detect: <pre> ({({1, 1,1}), ({1,-8,1}), ({1, 1,1})}) </pre> + </td><td> + <img src=illustration_3.gif width=67 height=67> + </td> -<p> horisontal edge detect (get the idea): +<p> <tr><td> + horisontal edge detect (get the idea): <pre> - ({({0, 0,0}) - ({1,-8,1}), + ({({0, 0,0}), + ({1,-2,1}), ({0, 0,0})}) </pre> + </td><td> + <img src=illustration_4.gif width=67 height=67> + </td> -<p> emboss (might prefer to begin with a <tt><a href=Image.image.html#grey>grey</a></tt> image): +<p> <tr><td rowspan=2> + emboss (might prefer to begin with a <tt><a href=Image.image.html#grey>grey</a></tt> image): <pre> - ({({2, 1, 0}) + ({({2, 1, 0}), ({1, 0,-1}), - ({0,-1, 2})}), 128,128,128, 5 + ({0,-1,-2})}), 128,128,128, 3 </pre> - -<p> This function is not very fast, and it's hard to + </td><td> + <img src=illustration_5.gif width=67 height=67> + </td><td> + <img src=illustration_6.gif width=67 height=67> + </td> + <tr><td></td><td>greyed</td></table> + +<p> This function is not very fast -- and it's hard to optimize it more, not using assembler. </blockquote> <h4>ARGUMENTS</h4> @@ -593,26 +620,6 @@ always casts to string... <tt><a href=Image.image.html#tobitmap>tobitmap</a></tt> </blockquote> -<hr> -<a name=ccw> </a> -<h4>SYNOPSIS</h4> -<blockquote> -<tt>object <b>ccw</b>()</tt> -</blockquote> - -<h4>DESCRIPTION</h4> - - -<blockquote> -rotates an image counter-clockwise, 90 degrees. -</blockquote> -<h4>RETURNS</h4> - - -<blockquote> -the new image object -</blockquote> - <hr> <a name=change_color> </a> <h4>SYNOPSIS</h4> @@ -894,26 +901,6 @@ Initializes a new image object. <tt><a href=Image.image.html>Image.image</a></tt> </blockquote> -<hr> -<a name=cw> </a> -<h4>SYNOPSIS</h4> -<blockquote> -<tt>object <b>cw</b>()</tt> -</blockquote> - -<h4>DESCRIPTION</h4> - - -<blockquote> -rotates an image clockwise, 90 degrees. -</blockquote> -<h4>RETURNS</h4> - - -<blockquote> -the new image object -</blockquote> - <hr> <a name=dct> </a> <h4>SYNOPSIS</h4> @@ -987,6 +974,14 @@ Makes an grey-scale image, for alpha-channel use. d.red=d.blue=d.green= ((o.red-p.red)�+(o.green-p.green)�+(o.blue-p.blue)�)>>8 </pre> + +<p> <table><tr valign=center> + <td><img src=lena.gif width=67 height=67></td> + <td><img src=illustration_8.gif width=67 height=67></td> + </tr><tr valign=center> + <td>original</td> + <td>->distancesq(255,0,128);</td> + </tr></table> </blockquote> <h4>ARGUMENTS</h4> <blockquote><dl> @@ -1366,11 +1361,9 @@ the new image object <hr> <a name=hsv_to_rgb> </a> -<a name=rgb_to_hsv> </a> <h4>SYNOPSIS</h4> <blockquote> -<tt>object <b>rgb_to_hsv</b>()<br> -object <b>hsv_to_rgb</b>()</tt> +<tt>object <b>hsv_to_rgb</b>()</tt> </blockquote> <h4>DESCRIPTION</h4> @@ -1384,7 +1377,18 @@ Converts RGB data to HSV data, or the other way around. <p> When converting to RGB, the input data is asumed to be placed in the pixels as above. -<p> HSV to RGB calculation: +<p> <table><tr valign=center> + <td><img src=lena.gif width=67 height=67></td> + <td><img src=illustration_10.gif width=67 height=67></td> + <td><img src=illustration_11.gif width=67 height=67></td> + </tr><tr valign=center> + <td>original</td> + <td>->hsv_to_rgb();</td> + <td>the rainbow (below)</td> + </tr></table> + +<p> + HSV to RGB calculation: <pre> in = input pixel out = destination pixel @@ -1399,7 +1403,7 @@ Converts RGB data to HSV data, or the other way around. </pre> <p> Example: Nice rainbow. - <pre> + <pre> object i = Image.image(200,200); i = i->tuned_box(0,0, 200,200, ({ ({ 255,255,128 }), ({ 0,255,128 }), @@ -1487,6 +1491,14 @@ Maps all pixel colors to the colors given. <p> Method to find the correct color is linear search over the colors given, selecting the nearest in the color cube. Slow... + +<p> <table><tr valign=center> + <td><img src=lena.gif width=67 height=67></td> + <td><img src=illustration_13.gif width=67 height=67></td> + </tr><tr valign=center> + <td>original</td> + <td>->map_closest(({({255,0,0}),({255,255,255}),({0,0,0})}));</td> + </tr></table> </blockquote> <h4>ARGUMENTS</h4> <blockquote><dl> @@ -1507,37 +1519,6 @@ the new image object <tt><a href=Image.image.html#map_fs>map_fs</a></tt> </blockquote> -<hr> -<a name=map_closest> </a> -<h4>SYNOPSIS</h4> -<blockquote> -<tt>array(array(int)) <b>map_closest</b>(int num_colors)</tt> -</blockquote> - -<h4>DESCRIPTION</h4> - - -<blockquote> -Selects the best colors to represent the image. -</blockquote> -<h4>ARGUMENTS</h4> -<blockquote><dl> -<dt><tt>int num_colors</tt> - <dd>number of colors to return -</dl></blockquote> -<h4>RETURNS</h4> - - -<blockquote> -an array of colors -</blockquote> - - -<h4>SEE ALSO</h4> -<blockquote> <tt><a href=Image.image.html#map_fast>map_fast</a></tt>, - <tt><a href=Image.image.html#select_colors>select_colors</a></tt> -</blockquote> - <hr> <a name=map_fast> </a> <h4>SYNOPSIS</h4> @@ -1594,6 +1575,14 @@ Maps all pixel colors to the colors given. <p> Floyd-steinberg error correction is added to create a better-looking image, in many cases, anyway. + +<p> <table><tr valign=center> + <td><img src=lena.gif width=67 height=67></td> + <td><img src=illustration_15.gif width=67 height=67></td> + </tr><tr valign=center> + <td>original</td> + <td>->map_fs(({({255,0,0}),({255,255,255}),({0,0,0})}));</td> + </tr></table> </blockquote> <h4>ARGUMENTS</h4> <blockquote><dl> @@ -1626,12 +1615,13 @@ the new image object <blockquote> mirrors an image: - <pre> - +--+ +--+ - |x | <-> | x| - | .| |. | - +--+ +--+ - </pre> + <table><tr valign=center> + <td><img src=lena.gif width=67 height=67></td> + <td><img src=illustration_17.gif width=67 height=67></td> + </tr><tr valign=center> + <td>original</td> + <td>->mirrorx();</td> + </tr></table> </blockquote> <h4>RETURNS</h4> @@ -1641,10 +1631,10 @@ the new image object </blockquote> <hr> -<a name=mirrorx> </a> +<a name=mirrory> </a> <h4>SYNOPSIS</h4> <blockquote> -<tt>object <b>mirrorx</b>()</tt> +<tt>object <b>mirrory</b>()</tt> </blockquote> <h4>DESCRIPTION</h4> @@ -1652,12 +1642,13 @@ the new image object <blockquote> mirrors an image: - <pre> - +--+ +--+ - |x | <-> | .| - | .| |x | - +--+ +--+ - </pre> + <table><tr valign=center> + <td><img src=lena.gif width=67 height=67></td> + <td><img src=illustration_19.gif width=67 height=67></td> + </tr><tr valign=center> + <td>original</td> + <td>->mirrory();</td> + </tr></table> </blockquote> <hr> @@ -1679,6 +1670,14 @@ Recolor an image from intensity values. <p> The color is then calculated from the values given, v1 representing the intensity value of 0, vn representing max, and colors between representing intensity values between, linear. + +<p> <table><tr valign=center> + <td><img src=lena.gif width=67 height=67></td> + <td><img src=illustration_21.gif width=67 height=67></td> + </tr><tr valign=center> + <td>original</td> + <td>->grey()->modify_by_intensity(1,0,0, 0,({255,0,0}),({0,255,0}));</td> + </tr></table> </blockquote> <h4>ARGUMENTS</h4> <blockquote><dl> @@ -1967,18 +1966,22 @@ object <b>rotate_expand</b>(int|float angle, int r, int g, int&nb <blockquote> Rotates an image a certain amount of degrees (360� is a complete rotation) counter-clockwise: - <pre> - x - +--+ / \ - | | <-> x x - | | \ / - +--+ x - </pre> - The "expand" variant of functions stretches the + +<p> <table><tr valign=center> + <td><img src=lena.gif width=67 height=67></td> + <td><img src=illustration_23.gif width=87 height=88></td> + <td><img src=illustration_24.gif width=87 height=88></td> + </tr><tr valign=center> + <td>original</td> + <td>->rotate(15,255,0,0);</td> + <td>->rotate_expand(15);</td> + </tr></table> + +<p> The "expand" variant of functions stretches the image border pixels rather then filling with the given or current color. -<p> This rotate uses the skewx() and skewy() functions. +<p> This rotate uses the <tt><a href=Image.image.html#skewx>skewx</a></tt>() and <tt><a href=Image.image.html#skewy>skewy</a></tt>() functions. </blockquote> <h4>ARGUMENTS</h4> <blockquote><dl> @@ -1992,6 +1995,62 @@ Rotates an image a certain amount of degrees (360 <h4>RETURNS</h4> +<blockquote> +the new image object +</blockquote> + +<hr> +<a name=rotate_ccw> </a> +<h4>SYNOPSIS</h4> +<blockquote> +<tt>object <b>rotate_ccw</b>()</tt> +</blockquote> + +<h4>DESCRIPTION</h4> + + +<blockquote> +rotates an image counter-clockwise, 90 degrees. + +<p> <table><tr valign=center> + <td><img src=lena.gif width=67 height=67></td> + <td><img src=illustration_26.gif width=67 height=67></td> + </tr><tr valign=center> + <td>original</td> + <td>->rotate_ccw();</td> + </tr></table> +</blockquote> +<h4>RETURNS</h4> + + +<blockquote> +the new image object +</blockquote> + +<hr> +<a name=rotate_cw> </a> +<h4>SYNOPSIS</h4> +<blockquote> +<tt>object <b>rotate_cw</b>()</tt> +</blockquote> + +<h4>DESCRIPTION</h4> + + +<blockquote> +rotates an image clockwise, 90 degrees. + +<p> <table><tr valign=center> + <td><img src=lena.gif width=67 height=67></td> + <td><img src=illustration_28.gif width=67 height=67></td> + </tr><tr valign=center> + <td>original</td> + <td>->rotate_cw();</td> + </tr></table> +</blockquote> +<h4>RETURNS</h4> + + <blockquote> the new image object </blockquote> @@ -2057,6 +2116,50 @@ scales the image to a specified new size, the new image object </blockquote> +<hr> +<a name=select_colors> </a> +<h4>SYNOPSIS</h4> +<blockquote> +<tt>array(array(int)) <b>select_colors</b>(int num_colors)</tt> +</blockquote> + +<h4>DESCRIPTION</h4> + + +<blockquote> +Selects the best colors to represent the image. + +<p> + <table><tr valign=center> + <td><img src=lena.gif width=67 height=67></td> + <td><img src=illustration_30.gif width=67 height=67></td> + <td><img src=illustration_31.gif width=67 height=67></td> + <td><img src=illustration_32.gif width=67 height=67></td> + </tr><tr valign=center> + <td>original</td> + <td>2</td> + <td>8</td> + <td>32</td> + </tr></table> +</blockquote> +<h4>ARGUMENTS</h4> +<blockquote><dl> +<dt><tt>int num_colors</tt> + <dd>number of colors to return +</dl></blockquote> +<h4>RETURNS</h4> + + +<blockquote> +an array of colors +</blockquote> + + +<h4>SEE ALSO</h4> +<blockquote> <tt><a href=Image.image.html#map_fast>map_fast</a></tt>, + <tt><a href=Image.image.html#select_colors>select_colors</a></tt> +</blockquote> + <hr> <a name=select_from> </a> <h4>SYNOPSIS</h4> @@ -2180,12 +2283,16 @@ object <b>skewx_expand</b>(int yfactor, int r, int g, int b) <blockquote> Skews an image an amount of pixels or a factor; a skew-x is a transformation: - <pre> - +--+ +--+ - | | <-> / / - | | / / - +--+ +--+ - </pre> + +<p> <table><tr valign=center> + <td><img src=lena.gif width=67 height=67></td> + <td><img src=illustration_34.gif width=82 height=67></td> + <td><img src=illustration_35.gif width=82 height=67></td> + </tr><tr valign=center> + <td>original</td> + <td>->skewx(15,255,0,0);</td> + <td>->skewx_expand(15);</td> + </tr></table> </blockquote> <h4>ARGUMENTS</h4> <blockquote><dl> @@ -2229,16 +2336,18 @@ object <b>skewy_expand</b>(int xfactor, int r, int g, int b) <blockquote> Skews an image an amount of pixels or a factor; a skew-y is a transformation: - <pre> - + - /| - +--+ / | - | | <-> + + - | | | / - +--+ |/ - + - </pre> - The "expand" variant of functions stretches the + +<p> <table><tr valign=center> + <td><img src=lena.gif width=67 height=67></td> + <td><img src=illustration_37.gif width=67 height=82></td> + <td><img src=illustration_38.gif width=67 height=82></td> + </tr><tr valign=center> + <td>original</td> + <td>->skewy(15,255,0,0);</td> + <td>->skewy_expand(15);</td> + </tr></table> + +<p> The "expand" variant of functions stretches the image border pixels rather then filling with the given or current color. </blockquote> diff --git a/src/modules/Image/image.c b/src/modules/Image/image.c index 68787dffc7614a513d1a3dc8aa749b4ba6ff5b1a..ebce80bc854670266a28c3208b8ecf0bc779ea0a 100644 --- a/src/modules/Image/image.c +++ b/src/modules/Image/image.c @@ -1,4 +1,4 @@ -/* $Id: image.c,v 1.31 1997/05/29 19:37:34 mirar Exp $ */ +/* $Id: image.c,v 1.32 1997/05/29 22:45:03 mirar Exp $ */ /* **! module Image @@ -6,7 +6,7 @@ **! This module adds image-drawing and -manipulating **! capabilities to pike. **! note -**! $Id: image.c,v 1.31 1997/05/29 19:37:34 mirar Exp $<br> +**! $Id: image.c,v 1.32 1997/05/29 22:45:03 mirar Exp $<br> **! see also: Image.font, Image.image **! **! class image @@ -43,14 +43,14 @@ **! <ref>paste_mask</ref> **! **! getting subimages, scaling, rotating: <ref>autocrop</ref>, -**! <ref>ccw</ref>, -**! <ref>cw</ref>, **! <ref>clone</ref>, **! <ref>copy</ref>, **! <ref>dct</ref>, **! <ref>mirrorx</ref>, **! <ref>rotate</ref>, **! <ref>rotate_expand</ref>, +**! <ref>rotate_ccw</ref>, +**! <ref>rotate_cw</ref>, **! <ref>scale</ref>, **! <ref>skewx</ref>, **! <ref>skewx_expand</ref>, @@ -65,10 +65,11 @@ **! <ref>invert</ref>, **! <ref>map_closest</ref>, **! <ref>map_fast</ref>, +**! <ref>select_colors</ref>, **! <ref>modify_by_intensity</ref>, -**! <ref>select_from</ref> -**! <ref>rgb_to_hsv</ref> -**! <ref>hsv_to_rgb</ref> +**! <ref>select_from</ref>, +**! <ref>rgb_to_hsv</ref>, +**! <ref>hsv_to_rgb</ref> **! **! converting to other datatypes: <ref>cast</ref>, **! <ref>fromgif</ref>, @@ -106,7 +107,7 @@ #include "stralloc.h" #include "global.h" -RCSID("$Id: image.c,v 1.31 1997/05/29 19:37:34 mirar Exp $"); +RCSID("$Id: image.c,v 1.32 1997/05/29 22:45:03 mirar Exp $"); #include "pike_macros.h" #include "object.h" #include "constants.h" @@ -1528,7 +1529,7 @@ void image_threshold(INT32 args) /* -**! method object rgb_to_hsv() +**x method object rgb_to_hsv() **! method object hsv_to_rgb() **! Converts RGB data to HSV data, or the other way around. **! When converting to HSV, the resulting data is stored like this: @@ -1537,6 +1538,22 @@ void image_threshold(INT32 args) **! When converting to RGB, the input data is asumed to be placed in **! the pixels as above. **! +**! <table><tr valign=center> +**! <td><illustration> return lena(); </illustration></td> +**! <td><illustration> return lena()->hsv_to_rgb(); </illustration></td> +**! <td><illustration> +**! return image(67,67)->tuned_box(0,0, 67,67, +**! ({ ({ 255,255,128 }), ({ 0,255,128 }), +**! ({ 255,255,255 }), ({ 0,255,255 })})) +**! ->hsv_to_rgb(); +**! </illustration></td> +**! </tr><tr valign=center> +**! <td>original</td> +**! <td>->hsv_to_rgb();</td> +**! <td>the rainbow (below)</td> +**! </tr></table> +**! +**! **! HSV to RGB calculation: **! <pre> **! in = input pixel @@ -1552,13 +1569,13 @@ void image_threshold(INT32 args) **! </pre> **! **! Example: Nice rainbow. -**! <pre> +**! <pre> **! object i = Image.image(200,200); **! i = i->tuned_box(0,0, 200,200, **! ({ ({ 255,255,128 }), ({ 0,255,128 }), **! ({ 255,255,255 }), ({ 0,255,255 })})) **! ->hsv_to_rgb(); -**! </pre> +**! </pre> **! returns the new image object */ @@ -1652,6 +1669,15 @@ void image_hsv_to_rgb(INT32 args) **! ((o.red-p.red)�+(o.green-p.green)�+(o.blue-p.blue)�)>>8 **! </pre> **! +**! <table><tr valign=center> +**! <td><illustration> return lena(); </illustration></td> +**! <td><illustration> return lena()->distancesq(255,0,128); </illustration></td> +**! </tr><tr valign=center> +**! <td>original</td> +**! <td>->distancesq(255,0,128);</td> +**! </tr></table> +**! +**! **! returns the new image object **! **! arg int r @@ -1901,42 +1927,106 @@ void image_select_from(INT32 args) **! 1/k is sum of matrix, or sum of matrix multiplied with div. **! base is given by r,g,b and is normally black. **! +**! <table><tr><td rowspan=2> **! blur (ie a 2d gauss function): **! <pre> **! ({({1,2,1}), **! ({2,5,2}), **! ({1,2,1})}) **! </pre> +**! </td><td> +**! <illustration> +**! return lena()->apply_matrix( +**! ({({1,2,1}), +**! ({2,5,2}), +**! ({1,2,1})}) +**! ); +**! </illustration> +**! </td><td> +**! <illustration> +**! return lena(); +**! </illustration> +**! </td> +**! <tr><td></td><td>original</td> **! +**! <tr><td> **! sharpen (k>8, preferably 12 or 16): **! <pre> **! ({({-1,-1,-1}), **! ({-1, k,-1}), **! ({-1,-1,-1})}) **! </pre> +**! </td><td> +**! <illustration> +**! return lena()->apply_matrix( +**! ({({-1,-1,-1}), +**! ({-1,14,-1}), +**! ({-1,-1,-1})}) +**! ); +**! </illustration> +**! </td> **! +**! <tr><td> **! edge detect: **! <pre> **! ({({1, 1,1}), **! ({1,-8,1}), **! ({1, 1,1})}) **! </pre> +**! </td><td> +**! <illustration> +**! return lena()->apply_matrix( +**! ({({1, 1,1}), +**! ({1,-8,1}), +**! ({1, 1,1})}) +**! ); +**! </illustration> +**! </td> **! +**! <tr><td> **! horisontal edge detect (get the idea): **! <pre> -**! ({({0, 0,0}) -**! ({1,-8,1}), +**! ({({0, 0,0}), +**! ({1,-2,1}), **! ({0, 0,0})}) **! </pre> +**! </td><td> +**! <illustration> +**! return lena()->apply_matrix( +**! ({({0, 0,0}), +**! ({1,-2,1}), +**! ({0, 0,0})}) +**! ); +**! </illustration> +**! </td> **! +**! <tr><td rowspan=2> **! emboss (might prefer to begin with a <ref>grey</ref> image): **! <pre> -**! ({({2, 1, 0}) +**! ({({2, 1, 0}), **! ({1, 0,-1}), -**! ({0,-1, 2})}), 128,128,128, 5 +**! ({0,-1,-2})}), 128,128,128, 3 **! </pre> +**! </td><td> +**! <illustration> +**! return lena()->apply_matrix( +**! ({({2, 1, 0}), +**! ({1, 0,-1}), +**! ({0,-1,-2})}), 128,128,128, 3 +**! ); +**! </illustration> +**! </td><td> +**! <illustration> +**! return lena()->grey()->apply_matrix( +**! ({({2, 1, 0}), +**! ({1, 0,-1}), +**! ({0,-1,-2})}), 128,128,128, 3 +**! ); +**! </illustration> +**! </td> +**! <tr><td></td><td>greyed</td></table> **! -**! This function is not very fast, and it's hard to +**! This function is not very fast -- and it's hard to **! optimize it more, not using assembler. **! **! returns the new image object @@ -2080,6 +2170,14 @@ CHRONO("apply_matrix, end"); **! the intensity value of 0, vn representing max, and colors between **! representing intensity values between, linear. **! +**! <table><tr valign=center> +**! <td><illustration> return lena(); </illustration></td> +**! <td><illustration> return lena()->grey()->modify_by_intensity(1,0,0,0,({255,0,0}),({0,255,0})); </illustration></td> +**! </tr><tr valign=center> +**! <td>original</td> +**! <td>->grey()->modify_by_intensity(1,0,0, 0,({255,0,0}),({0,255,0}));</td> +**! </tr></table> +**! **! returns the new image object **! **! arg int r @@ -2200,6 +2298,14 @@ void image_modify_by_intensity(INT32 args) **! over the colors given, selecting the nearest in the **! color cube. Slow... **! +**! <table><tr valign=center> +**! <td><illustration> return lena(); </illustration></td> +**! <td><illustration> return lena()->map_closest(({({255,0,0}),({255,255,255}),({0,0,0})})); </illustration></td> +**! </tr><tr valign=center> +**! <td>original</td> +**! <td>->map_closest(({({255,0,0}),({255,255,255}),({0,0,0})}));</td> +**! </tr></table> +**! **! returns the new image object **! **! arg array(array(int)) color @@ -2306,6 +2412,14 @@ static void image_map_fast(INT32 args) **! Floyd-steinberg error correction is added to create **! a better-looking image, in many cases, anyway. **! +**! <table><tr valign=center> +**! <td><illustration> return lena(); </illustration></td> +**! <td><illustration> return lena()->map_fs(({({255,0,0}),({255,255,255}),({0,0,0})})); </illustration></td> +**! </tr><tr valign=center> +**! <td>original</td> +**! <td>->map_fs(({({255,0,0}),({255,255,255}),({0,0,0})}));</td> +**! </tr></table> +**! **! returns the new image object **! **! arg array(array(int)) color @@ -2365,11 +2479,23 @@ static void image_map_fs(INT32 args) } /* -**! method array(array(int)) map_closest(int num_colors) +**! method array(array(int)) select_colors(int num_colors) **! Selects the best colors to represent the image. **! **! returns an array of colors **! +**! <table><tr valign=center> +**! <td><illustration> return lena(); </illustration></td> +**! <td><illustration> return lena()->map_closest(lena()->select_colors(2)); </illustration></td> +**! <td><illustration> return lena()->map_closest(lena()->select_colors(8)); </illustration></td> +**! <td><illustration> return lena()->map_closest(lena()->select_colors(32)); </illustration></td> +**! </tr><tr valign=center> +**! <td>original</td> +**! <td>2</td> +**! <td>8</td> +**! <td>32</td> +**! </tr></table> +**! **! arg int num_colors **! number of colors to return **! diff --git a/src/modules/Image/matrix.c b/src/modules/Image/matrix.c index a8a9891e41cd0290d24b1311af79e9bbf543afb3..5968e2af603bdf9329c8b7ead73fd4c535f661a2 100644 --- a/src/modules/Image/matrix.c +++ b/src/modules/Image/matrix.c @@ -1,9 +1,9 @@ -/* $Id: matrix.c,v 1.6 1997/05/29 19:37:52 mirar Exp $ */ +/* $Id: matrix.c,v 1.7 1997/05/29 22:45:07 mirar Exp $ */ /* **! module Image **! note -**! $Id: matrix.c,v 1.6 1997/05/29 19:37:52 mirar Exp $<br> +**! $Id: matrix.c,v 1.7 1997/05/29 22:45:07 mirar Exp $<br> **! class image */ @@ -347,8 +347,17 @@ void image_scale(INT32 args) } /* -**! method object ccw() +**! method object rotate_ccw() **! rotates an image counter-clockwise, 90 degrees. +**! +**! <table><tr valign=center> +**! <td><illustration> return lena(); </illustration></td> +**! <td><illustration> return lena()->rotate_ccw(); </illustration></td> +**! </tr><tr valign=center> +**! <td>original</td> +**! <td>->rotate_ccw();</td> +**! </tr></table> +**! **! returns the new image object **! **! @@ -446,8 +455,16 @@ void img_ccw(struct image *is,struct image *id) } /* -**! method object cw() +**! method object rotate_cw() **! rotates an image clockwise, 90 degrees. +**! +**! <table><tr valign=center> +**! <td><illustration> return lena(); </illustration></td> +**! <td><illustration> return lena()->rotate_cw(); </illustration></td> +**! </tr><tr valign=center> +**! <td>original</td> +**! <td>->rotate_cw();</td> +**! </tr></table> **! returns the new image object **! **! @@ -493,12 +510,13 @@ void image_cw(INT32 args) /* **! method object mirrorx() **! mirrors an image: -**! <pre> -**! +--+ +--+ -**! |x | <-> | x| -**! | .| |. | -**! +--+ +--+ -**! </pre> +**! <table><tr valign=center> +**! <td><illustration> return lena(); </illustration></td> +**! <td><illustration> return lena()->mirrorx(); </illustration></td> +**! </tr><tr valign=center> +**! <td>original</td> +**! <td>->mirrorx();</td> +**! </tr></table> **! returns the new image object **! **! @@ -541,15 +559,15 @@ void image_mirrorx(INT32 args) } /* -**! method object mirrorx() +**! method object mirrory() **! mirrors an image: -**! <pre> -**! +--+ +--+ -**! |x | <-> | .| -**! | .| |x | -**! +--+ +--+ -**! </pre> -**! +**! <table><tr valign=center> +**! <td><illustration> return lena(); </illustration></td> +**! <td><illustration> return lena()->mirrory(); </illustration></td> +**! </tr><tr valign=center> +**! <td>original</td> +**! <td>->mirrory();</td> +**! </tr></table> **! */ @@ -759,12 +777,17 @@ CHRONO("skewy end\n"); **! method object skewx_expand(int yfactor,int r,int g,int b) **! Skews an image an amount of pixels or a factor; **! a skew-x is a transformation: -**! <pre> -**! +--+ +--+ -**! | | <-> / / -**! | | / / -**! +--+ +--+ -**! </pre> +**! +**! <table><tr valign=center> +**! <td><illustration> return lena(); </illustration></td> +**! <td><illustration> return lena()->skewx(15,255,0,0); </illustration></td> +**! <td><illustration> return lena()->skewx_expand(15); </illustration></td> +**! </tr><tr valign=center> +**! <td>original</td> +**! <td>->skewx(15,255,0,0);</td> +**! <td>->skewx_expand(15);</td> +**! </tr></table> +**! **! returns the new image object **! arg int x **! the number of pixels @@ -817,15 +840,17 @@ void image_skewx(INT32 args) **! method object skewy_expand(int xfactor,int r,int g,int b) **! Skews an image an amount of pixels or a factor; **! a skew-y is a transformation: -**! <pre> -**! + -**! /| -**! +--+ / | -**! | | <-> + + -**! | | | / -**! +--+ |/ -**! + -**! </pre> +**! +**! <table><tr valign=center> +**! <td><illustration> return lena(); </illustration></td> +**! <td><illustration> return lena()->skewy(15,255,0,0); </illustration></td> +**! <td><illustration> return lena()->skewy_expand(15); </illustration></td> +**! </tr><tr valign=center> +**! <td>original</td> +**! <td>->skewy(15,255,0,0);</td> +**! <td>->skewy_expand(15);</td> +**! </tr></table> +**! **! The "expand" variant of functions stretches the **! image border pixels rather then filling with **! the given or current color. @@ -989,18 +1014,22 @@ void img_rotate(INT32 args,int xpn) **! method object rotate_expand(int|float angle,int r,int g,int b) **! Rotates an image a certain amount of degrees (360� is **! a complete rotation) counter-clockwise: -**! <pre> -**! x -**! +--+ / \ -**! | | <-> x x -**! | | \ / -**! +--+ x -**! </pre> +**! +**! <table><tr valign=center> +**! <td><illustration> return lena(); </illustration></td> +**! <td><illustration> return lena()->rotate(15,255,0,0); </illustration></td> +**! <td><illustration> return lena()->rotate_expand(15); </illustration></td> +**! </tr><tr valign=center> +**! <td>original</td> +**! <td>->rotate(15,255,0,0);</td> +**! <td>->rotate_expand(15);</td> +**! </tr></table> +**! **! The "expand" variant of functions stretches the **! image border pixels rather then filling with **! the given or current color. **! -**! This rotate uses the skewx() and skewy() functions. +**! This rotate uses the <ref>skewx</ref>() and <ref>skewy</ref>() functions. **! returns the new image object **! arg int|float angle **! the number of degrees to rotate diff --git a/src/modules/Image/mkdoc.pike b/src/modules/Image/mkdoc.pike index 9cd9fa0b3894565831a49bb28466419d5dff6782..7a2d4839b3c041bb9dda962ce16b414101dc4e14 100644 --- a/src/modules/Image/mkdoc.pike +++ b/src/modules/Image/mkdoc.pike @@ -2,6 +2,10 @@ import Stdio; import Array; mapping parse=([]); +int illustration_counter; + +string illustration_code=read_bytes("illustration.pike"); +object lena_image=Image.image()->fromppm(read_file("doc/lena.ppm")); /* @@ -178,6 +182,7 @@ string fixdesc(string s,string prefix) s=stripws(s); string t,u,v; + t=s; s=""; while (sscanf(t,"%s<ref>%s</ref>%s",t,u,v)==3) { @@ -185,6 +190,25 @@ string fixdesc(string s,string prefix) t=v; } s+=t; + + t=s; s=""; + while (sscanf(t,"%s<illustration>%s</illustration>%s",t,u,v)==3) + { + s+=t; + mixed err=catch { + object x=compile_string(replace(illustration_code,"***the string***",u))(); + x->lena_image=lena_image; + u=x->doit("illustration_"+illustration_counter+++".gif"); + }; + if (err) + { + stderr->write("error while compiling and running\n"+u+"\n"); + } + else s+=u; + t=v; + } + s+=t; + return htmlify(replace(s,"\n\n","\n\n<p>")); }