EVOLUTION-MANAGER
Edit File: convert_colour.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Convert between colour spaces</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for convert_colour {farver}"><tr><td>convert_colour {farver}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Convert between colour spaces</h2> <h3>Description</h3> <p>This function lets you convert between different representations of colours. The API is reminiscent of <code><a href="../../grDevices/html/convertColor.html">grDevices::convertColor()</a></code>, but the performance is much better. It is not assured that <code>grDevices::convertColor()</code> and <code>convert_colour()</code> provide numerically equivalent conversion at 16bit level as the formula used are potentially slightly different. For all intend and purpose, the resulting colours will be equivalent though. </p> <h3>Usage</h3> <pre> convert_colour(colour, from, to, white_from = "D65", white_to = white_from) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>colour</code></td> <td> <p>A numeric matrix (or an object coercible to one) with colours encoded in the rows and the different colour space values in the columns. For all colourspaces except <code>'cmyk'</code> this will mean a matrix with three columns - for <code>'cmyk'</code> it means four columns.</p> </td></tr> <tr valign="top"><td><code>from, to</code></td> <td> <p>The input and output colour space. Allowed values are: <code>"cmy"</code>, <code>"cmyk"</code>, <code>"hsl"</code>, <code>"hsb"</code>, <code>"hsv"</code>, <code>"lab"</code> (CIE L*ab), <code>"hunterlab"</code> (Hunter Lab), <code>"lch"</code> (CIE Lch(ab) / polarLAB), <code>"luv"</code>, <code>"rgb"</code> (sRGB), <code>"xyz"</code>, <code>"yxy"</code> (CIE xyY), or <code>"hcl"</code> (CIE Lch(uv) / polarLuv)</p> </td></tr> <tr valign="top"><td><code>white_from, white_to</code></td> <td> <p>The white reference of the from and to colour space. Will only have an effect for relative colour spaces such as Lab and luv. Any value accepted by <code><a href="as_white_ref.html">as_white_ref()</a></code> allowed.</p> </td></tr> </table> <h3>Value</h3> <p>A numeric matrix with the same number of rows as <code>colour</code> and either 3 or 4 columns depending on the value of <code>to</code>. If <code>colour</code> is given as a <code>data.frame</code> the output will be a data.frame as well </p> <h3>Handling of non-finite and out of bounds values</h3> <p><code>NA</code>, <code>NaN</code>, <code>-Inf</code>, and <code>Inf</code> are treated as invalid input and will result in <code>NA</code> values for the colour. If a given colourspace has finite bounds in some of their channels, the input will be capped before conversion, and the output will be capped before returning, so that both input and output colours are valid colours in their respective space. This means that converting back and forth between two colourspaces may result in a change in the colour if the gamut of one of the spaces is less than the other. </p> <h3>Note</h3> <p>This function and <code><a href="../../grDevices/html/convertColor.html">convertColor()</a></code> are not numerically equivalent due to rounding errors, but for all intend and purpose they give the same results. </p> <h3>See Also</h3> <p><code><a href="../../grDevices/html/convertColor.html">grDevices::convertColor()</a></code>, <code><a href="../../grDevices/html/col2rgb.html">grDevices::col2rgb()</a></code> </p> <h3>Examples</h3> <pre> spectrum <- decode_colour(rainbow(10)) spec_lab <- convert_colour(spectrum, 'rgb', 'lab') spec_lab # Convert between different white references convert_colour(spec_lab, 'lab', 'lab', white_from = 'D65', white_to = 'F10') </pre> <hr /><div style="text-align: center;">[Package <em>farver</em> version 2.0.3 <a href="00Index.html">Index</a>]</div> </body></html>