<html lang="en"> <head> <title>Displaying Images - GNU Octave</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="GNU Octave"> <meta name="generator" content="makeinfo 4.13"> <link title="Top" rel="start" href="index.html#Top"> <link rel="up" href="Image-Processing.html#Image-Processing" title="Image Processing"> <link rel="prev" href="Loading-and-Saving-Images.html#Loading-and-Saving-Images" title="Loading and Saving Images"> <link rel="next" href="Representing-Images.html#Representing-Images" title="Representing Images"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } --></style> </head> <body> <div class="node"> <a name="Displaying-Images"></a> <p> Next: <a rel="next" accesskey="n" href="Representing-Images.html#Representing-Images">Representing Images</a>, Previous: <a rel="previous" accesskey="p" href="Loading-and-Saving-Images.html#Loading-and-Saving-Images">Loading and Saving Images</a>, Up: <a rel="up" accesskey="u" href="Image-Processing.html#Image-Processing">Image Processing</a> <hr> </div> <h3 class="section">32.2 Displaying Images</h3> <p>A natural part of image processing is visualization of an image. The most basic function for this is the <code>imshow</code> function that shows the image given in the first input argument. <!-- imshow scripts/image/imshow.m --> <p><a name="doc_002dimshow"></a> <div class="defun"> — Function File: <b>imshow</b> (<var>im</var>)<var><a name="index-imshow-2897"></a></var><br> — Function File: <b>imshow</b> (<var>im, limits</var>)<var><a name="index-imshow-2898"></a></var><br> — Function File: <b>imshow</b> (<var>im, map</var>)<var><a name="index-imshow-2899"></a></var><br> — Function File: <b>imshow</b> (<var>rgb, <small class="dots">...</small></var>)<var><a name="index-imshow-2900"></a></var><br> — Function File: <b>imshow</b> (<var>filename</var>)<var><a name="index-imshow-2901"></a></var><br> — Function File: <b>imshow</b> (<var><small class="dots">...</small>, string_param1, value1, <small class="dots">...</small></var>)<var><a name="index-imshow-2902"></a></var><br> — Function File: <var>h</var> = <b>imshow</b> (<var><small class="dots">...</small></var>)<var><a name="index-imshow-2903"></a></var><br> <blockquote><p>Display the image <var>im</var>, where <var>im</var> can be a 2-dimensional (gray-scale image) or a 3-dimensional (RGB image) matrix. <p>If <var>limits</var> is a 2-element vector <code>[</code><var>low</var><code>, </code><var>high</var><code>]</code>, the image is shown using a display range between <var>low</var> and <var>high</var>. If an empty matrix is passed for <var>limits</var>, the display range is computed as the range between the minimal and the maximal value in the image. <p>If <var>map</var> is a valid color map, the image will be shown as an indexed image using the supplied color map. <p>If a file name is given instead of an image, the file will be read and shown. <p>If given, the parameter <var>string_param1</var> has value <var>value1</var>. <var>string_param1</var> can be any of the following: <dl> <dt>"displayrange"<dd><var>value1</var> is the display range as described above. </dl> <p>The optional return value <var>h</var> is a graphics handle to the image. <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dimage.html#doc_002dimage">image</a>, <a href="doc_002dimagesc.html#doc_002dimagesc">imagesc</a>, <a href="doc_002dcolormap.html#doc_002dcolormap">colormap</a>, <a href="doc_002dgray2ind.html#doc_002dgray2ind">gray2ind</a>, <a href="doc_002drgb2ind.html#doc_002drgb2ind">rgb2ind</a>. </p></blockquote></div> <!-- image scripts/image/image.m --> <p><a name="doc_002dimage"></a> <div class="defun"> — Function File: <b>image</b> (<var>img</var>)<var><a name="index-image-2904"></a></var><br> — Function File: <b>image</b> (<var>x, y, img</var>)<var><a name="index-image-2905"></a></var><br> — Function File: <var>h</var> = <b>image</b> (<var><small class="dots">...</small></var>)<var><a name="index-image-2906"></a></var><br> <blockquote><p>Display a matrix as a color image. The elements of <var>img</var> are indices into the current colormap, and the colormap will be scaled so that the extremes of <var>img</var> are mapped to the extremes of the colormap. <p>The axis values corresponding to the matrix elements are specified in <var>x</var> and <var>y</var>. If you're not using gnuplot 4.2 or later, these variables are ignored. <p>Implementation Note: The origin (0, 0) for images is located in the upper left. For ordinary plots, the origin is located in the lower left. Octave handles this inversion by plotting the data normally, and then reversing the direction of the y-axis by setting the <code>ydir</code> property to <code>"reverse"</code>. This has implications whenever an image and an ordinary plot need to be overlaid. The recommended solution is to display the image and then plot the reversed ydata using, for example, <code>flipud (ydata,1)</code>. <p>The optional return value <var>h</var> is a graphics handle to the image. <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dimshow.html#doc_002dimshow">imshow</a>, <a href="doc_002dimagesc.html#doc_002dimagesc">imagesc</a>, <a href="doc_002dcolormap.html#doc_002dcolormap">colormap</a>. </p></blockquote></div> <!-- imagesc scripts/image/imagesc.m --> <p><a name="doc_002dimagesc"></a> <div class="defun"> — Function File: <b>imagesc</b> (<var>A</var>)<var><a name="index-imagesc-2907"></a></var><br> — Function File: <b>imagesc</b> (<var>x, y, A</var>)<var><a name="index-imagesc-2908"></a></var><br> — Function File: <b>imagesc</b> (<var><small class="dots">...</small>, limits</var>)<var><a name="index-imagesc-2909"></a></var><br> — Function File: <b>imagesc</b> (<var>h, <small class="dots">...</small></var>)<var><a name="index-imagesc-2910"></a></var><br> — Function File: <var>h</var> = <b>imagesc</b> (<var><small class="dots">...</small></var>)<var><a name="index-imagesc-2911"></a></var><br> <blockquote><p>Display a scaled version of the matrix <var>A</var> as a color image. The colormap is scaled so that the entries of the matrix occupy the entire colormap. If <var>limits</var> = [<var>lo</var>, <var>hi</var>] are given, then that range is set to the 'clim' of the current axes. <p>The axis values corresponding to the matrix elements are specified in <var>x</var> and <var>y</var>, either as pairs giving the minimum and maximum values for the respective axes, or as values for each row and column of the matrix <var>A</var>. <p>The optional return value <var>h</var> is a graphics handle to the image. <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dimage.html#doc_002dimage">image</a>, <a href="doc_002dimshow.html#doc_002dimshow">imshow</a>, <a href="doc_002dcaxis.html#doc_002dcaxis">caxis</a>. </p></blockquote></div> </body></html>