| 1 | |
| 2 | <refentry id="imagegetpixel"> |
| 3 | <indexterm id="IndexImagegetpixel"><primary>imagegetpixel</primary></indexterm> |
| 4 | <refentryinfo><title>Image Processing Opcodes</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>imagegetpixel</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | <refnamediv> |
| 10 | <refname>imagegetpixel</refname> |
| 11 | <refpurpose> |
| 12 | Return the RGB pixel values of a previously opened or created image. |
| 13 | </refpurpose> |
| 14 | </refnamediv> |
| 15 | |
| 16 | <refsect1> |
| 17 | <title>Description</title> |
| 18 | <para>Plugin opcode in image. This opcode is part of the plugin repository and has to be installed separately. |
| 19 | The plugin repository can be found here: <ulink url="https://github.com/csound/plugins"><citetitle>https://github.com/csound/plugins</citetitle></ulink></para> |
| 20 | <para>Return the RGB pixel values of a previously opened or created image. An image can be loaded with <link linkend="imageload"><citetitle>imageload</citetitle></link>. An empty image can be created with <link linkend="imagecreate"><citetitle>imagecreate</citetitle></link>. |
| 21 | </para> |
| 22 | </refsect1> |
| 23 | |
| 24 | <refsect1> |
| 25 | <title>Syntax</title> |
| 26 | <synopsis>ared, agreen, ablue <command>imagegetpixel</command> iimagenum, ax, ay</synopsis> |
| 27 | <synopsis>kred, kgreen, kblue <command>imagegetpixel</command> iimagenum, kx, ky</synopsis> |
| 28 | </refsect1> |
| 29 | |
| 30 | <refsect1> |
| 31 | <title>Initialization</title> |
| 32 | <para> |
| 33 | <emphasis>iimagenum</emphasis> -- the reference of the image. It should be a value returned by <link linkend="imageload"><citetitle>imageload</citetitle></link> or <link linkend="imagecreate"><citetitle>imagecreate</citetitle></link>. |
| 34 | </para> |
| 35 | </refsect1> |
| 36 | |
| 37 | <refsect1> |
| 38 | <title>Performance</title> |
| 39 | <para> |
| 40 | <emphasis>ax (kx)</emphasis> -- horizontal pixel position (must be a float from 0 to 1). |
| 41 | </para> |
| 42 | <para> |
| 43 | <emphasis>ay (ky)</emphasis> -- vertical pixel position (must be a float from 0 to 1). |
| 44 | </para> |
| 45 | <para> |
| 46 | <emphasis>ared (kred)</emphasis> -- red value of the pixel (mapped to a float from 0 to 1). |
| 47 | </para> |
| 48 | <para> |
| 49 | <emphasis>agreen (kgreen)</emphasis> -- green value of the pixel (mapped to a float from 0 to 1). |
| 50 | </para> |
| 51 | <para> |
| 52 | <emphasis>ablue (kblue)</emphasis> -- blue value of the pixel (mapped to a float from 0 to 1). |
| 53 | </para> |
| 54 | </refsect1> |
| 55 | |
| 56 | <refsect1> |
| 57 | <title>Examples</title> |
| 58 | <para> |
| 59 | Here is an example of the imagegetpixel opcode. It uses the files <ulink url="examples/imagegetpixel.csd"><citetitle>imagegetpixel.csd</citetitle></ulink>, <ulink url="examples/imageOpcode01.png"><citetitle>imageOpcode01.png</citetitle></ulink> and <ulink url="examples/imageOpcode02.png"><citetitle>imageOpcode02.png</citetitle></ulink>. |
| 60 | <example> |
| 61 | <title>Example of the imagegetpixel opcode.</title> |
| 62 | <xi:include href="examples-xml/imagegetpixel.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 63 | </example> |
| 64 | <para> |
| 65 | Here is what the images <citetitle>imageOpcode01.png</citetitle> and <citetitle>imageOpcode02.png</citetitle>for the <citetitle>imagegetpixel</citetitle> example look like: |
| 66 | </para> |
| 67 | <imageobject> |
| 68 | <imagedata fileref="images/imageOpcode01small.png" format="PNG"/> |
| 69 | </imageobject> |
| 70 | <imageobject> |
| 71 | <imagedata fileref="images/imageOpcode02small.png" format="PNG"/> |
| 72 | </imageobject> |
| 73 | <para> |
| 74 | Here is a musical example of the imagegetpixel opcode. It uses the files <ulink url="examples/imagegetpixel-musical.csd"><citetitle>imagegetpixel-musical.csd</citetitle></ulink> and <ulink url="examples/imageOpcode03.png"><citetitle>imageOpcode03.png</citetitle></ulink>. |
| 75 | </para> |
| 76 | <example> |
| 77 | <title>Example of the imagegetpixel opcode.</title> |
| 78 | <xi:include href="examples-xml/imagegetpixel-musical.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 79 | </example> |
| 80 | <para> |
| 81 | This is what the image <citetitle>imageOpcode03.png</citetitle> for the <citetitle>imagegetpixel-musical</citetitle> example looks like: |
| 82 | </para> |
| 83 | <imageobject> |
| 84 | <imagedata fileref="examples/imageOpcode03.png" format="PNG"/> |
| 85 | </imageobject> |
| 86 | </para> |
| 87 | </refsect1> |
| 88 | |
| 89 | <refsect1> |
| 90 | <title>See also</title> |
| 91 | <para><link linkend="ImageopcodesTop"><citetitle>Image processing opcodes</citetitle></link></para> |
| 92 | </refsect1> |
| 93 | |
| 94 | <refsect1> |
| 95 | <title>Credits</title> |
| 96 | <para> |
| 97 | <simplelist> |
| 98 | <member>Author: Cesare Marilungo</member> |
| 99 | </simplelist> |
| 100 | </para> |
| 101 | <para>New in version 5.08</para> |
| 102 | </refsect1> |
| 103 | </refentry> |