1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051
|
<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Representing Images (GNU Octave (version 10.3.0))</title>
<meta name="description" content="Representing Images (GNU Octave (version 10.3.0))">
<meta name="keywords" content="Representing Images (GNU Octave (version 10.3.0))">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link href="index.html" rel="start" title="Top">
<link href="Concept-Index.html" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Image-Processing.html" rel="up" title="Image Processing">
<link href="Plotting-on-top-of-Images.html" rel="next" title="Plotting on top of Images">
<link href="Displaying-Images.html" rel="prev" title="Displaying Images">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
div.example {margin-left: 3.2em}
kbd.kbd {font-style: oblique}
span:hover a.copiable-link {visibility: visible}
strong.def-name {font-family: monospace; font-weight: bold; font-size: larger}
-->
</style>
<link rel="stylesheet" type="text/css" href="octave.css">
</head>
<body lang="en">
<div class="section-level-extent" id="Representing-Images">
<div class="nav-panel">
<p>
Next: <a href="Plotting-on-top-of-Images.html" accesskey="n" rel="next">Plotting on top of Images</a>, Previous: <a href="Displaying-Images.html" accesskey="p" rel="prev">Displaying Images</a>, Up: <a href="Image-Processing.html" accesskey="u" rel="up">Image Processing</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h3 class="section" id="Representing-Images-1"><span>32.3 Representing Images<a class="copiable-link" href="#Representing-Images-1"> ¶</a></span></h3>
<p>In general Octave supports four different kinds of images, grayscale
images, RGB images, binary images, and indexed images. A grayscale
image is represented with an M-by-N matrix in which each
element corresponds to the intensity of a pixel. An RGB image is
represented with an M-by-N-by-3 array where each
3-vector corresponds to the red, green, and blue intensities of each
pixel.
</p>
<p>The actual meaning of the value of a pixel in a grayscale or RGB
image depends on the class of the matrix. If the matrix is of class
<code class="code">double</code> pixel intensities are between 0 and 1, if it is of class
<code class="code">uint8</code> intensities are between 0 and 255, and if it is of class
<code class="code">uint16</code> intensities are between 0 and 65535.
</p>
<p>A binary image is an M-by-N matrix of class <code class="code">logical</code>.
A pixel in a binary image is black if it is <code class="code">false</code> and white
if it is <code class="code">true</code>.
</p>
<p>An indexed image consists of an M-by-N matrix of integers
and a C-by-3 color map. Each integer corresponds to an
index in the color map, and each row in the color map corresponds to
an RGB color. The color map must be of class <code class="code">double</code> with values
between 0 and 1.
</p>
<p>The following convenience functions are available for conversion between image
formats.
</p>
<a class="anchor" id="XREFim2double"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-im2double"><span><code class="def-type"><var class="var">dimg</var> =</code> <strong class="def-name">im2double</strong> <code class="def-code-arguments">(<var class="var">img</var>)</code><a class="copiable-link" href="#index-im2double"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-im2double-1"><span><code class="def-type"><var class="var">dimg</var> =</code> <strong class="def-name">im2double</strong> <code class="def-code-arguments">(<var class="var">img</var>, "indexed")</code><a class="copiable-link" href="#index-im2double-1"> ¶</a></span></dt>
<dd><p>Convert image to double precision.
</p>
<p>The conversion of <var class="var">img</var> to double precision, is dependent on the type of
input image. The following input classes are supported:
</p>
<dl class="table">
<dt>‘<samp class="samp">uint8, uint16, and int16</samp>’</dt>
<dd><p>The range of values from the class is scaled to the interval [0 1].
</p>
</dd>
<dt>‘<samp class="samp">logical</samp>’</dt>
<dd><p>True and false values are assigned a value of 1 and 0 respectively.
</p>
</dd>
<dt>‘<samp class="samp">single</samp>’</dt>
<dd><p>Values are cast to double.
</p>
</dd>
<dt>‘<samp class="samp">double</samp>’</dt>
<dd><p>Returns the same image.
</p>
</dd>
</dl>
<p>If <var class="var">img</var> is an indexed image, then the second argument should be the
string <code class="code">"indexed"</code>. If so, then <var class="var">img</var> must either be of floating
point class, or unsigned integer class and it will simply be cast to double.
If it is an integer class, an offset of +1 is applied.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="Numeric-Data-Types.html#XREFdouble">double</a>.
</p></dd></dl>
<a class="anchor" id="XREFgray2ind"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-gray2ind"><span><code class="def-type"><var class="var">img</var> =</code> <strong class="def-name">gray2ind</strong> <code class="def-code-arguments">(<var class="var">I</var>)</code><a class="copiable-link" href="#index-gray2ind"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-gray2ind-1"><span><code class="def-type"><var class="var">img</var> =</code> <strong class="def-name">gray2ind</strong> <code class="def-code-arguments">(<var class="var">I</var>, <var class="var">n</var>)</code><a class="copiable-link" href="#index-gray2ind-1"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-gray2ind-2"><span><code class="def-type"><var class="var">img</var> =</code> <strong class="def-name">gray2ind</strong> <code class="def-code-arguments">(<var class="var">BW</var>)</code><a class="copiable-link" href="#index-gray2ind-2"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-gray2ind-3"><span><code class="def-type"><var class="var">img</var> =</code> <strong class="def-name">gray2ind</strong> <code class="def-code-arguments">(<var class="var">BW</var>, <var class="var">n</var>)</code><a class="copiable-link" href="#index-gray2ind-3"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-gray2ind-4"><span><code class="def-type">[<var class="var">img</var>, <var class="var">map</var>] =</code> <strong class="def-name">gray2ind</strong> <code class="def-code-arguments">(…)</code><a class="copiable-link" href="#index-gray2ind-4"> ¶</a></span></dt>
<dd><p>Convert a grayscale or binary intensity image to an indexed image.
</p>
<p>The indexed image will consist of <var class="var">n</var> different intensity values.
If not given <var class="var">n</var> defaults to 64 for grayscale images or 2 for binary
black and white images.
</p>
<p>The output <var class="var">img</var> is of class uint8 if <var class="var">n</var> is less than or equal to
256; Otherwise the return class is uint16.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFind2gray">ind2gray</a>, <a class="ref" href="#XREFrgb2ind">rgb2ind</a>.
</p></dd></dl>
<a class="anchor" id="XREFind2gray"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-ind2gray"><span><code class="def-type"><var class="var">I</var> =</code> <strong class="def-name">ind2gray</strong> <code class="def-code-arguments">(<var class="var">x</var>, <var class="var">map</var>)</code><a class="copiable-link" href="#index-ind2gray"> ¶</a></span></dt>
<dd><p>Convert a color indexed image to a grayscale intensity image.
</p>
<p>The image <var class="var">x</var> must be an indexed image which will be converted using the
colormap <var class="var">map</var>. If <var class="var">map</var> does not contain enough colors for the
image, pixels in <var class="var">x</var> outside the range are mapped to the last color in
the map before conversion to grayscale.
</p>
<p>The output <var class="var">I</var> is of the same class as the input <var class="var">x</var> and may be
one of <code class="code">uint8</code>, <code class="code">uint16</code>, <code class="code">single</code>, or <code class="code">double</code>.
</p>
<p>Implementation Note: There are several ways of converting colors to
grayscale intensities. This functions uses the luminance value obtained
from <code class="code">rgb2gray</code> which is <code class="code">I = 0.299*R + 0.587*G + 0.114*B</code>.
Other possibilities include the value component from <code class="code">rgb2hsv</code> or
using a single color channel from <code class="code">ind2rgb</code>.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFgray2ind">gray2ind</a>, <a class="ref" href="#XREFind2rgb">ind2rgb</a>.
</p></dd></dl>
<a class="anchor" id="XREFrgb2ind"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-rgb2ind"><span><code class="def-type">[<var class="var">x</var>, <var class="var">map</var>] =</code> <strong class="def-name">rgb2ind</strong> <code class="def-code-arguments">(<var class="var">rgb</var>)</code><a class="copiable-link" href="#index-rgb2ind"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-rgb2ind-1"><span><code class="def-type">[<var class="var">x</var>, <var class="var">map</var>] =</code> <strong class="def-name">rgb2ind</strong> <code class="def-code-arguments">(<var class="var">R</var>, <var class="var">G</var>, <var class="var">B</var>)</code><a class="copiable-link" href="#index-rgb2ind-1"> ¶</a></span></dt>
<dd><p>Convert an image in red-green-blue (RGB) color space to an indexed image.
</p>
<p>The input image <var class="var">rgb</var> can be specified as a single matrix of size
MxNx3, or as three separate variables, <var class="var">R</var>, <var class="var">G</var>, and
<var class="var">B</var>, its three color channels, red, green, and blue.
</p>
<p>It outputs an indexed image <var class="var">x</var> and a colormap <var class="var">map</var> to interpret
an image exactly the same as the input. No dithering or other form of color
quantization is performed. The output class of the indexed image <var class="var">x</var>
can be uint8, uint16 or double, whichever is required to specify the
number of unique colors in the image (which will be equal to the number
of rows in <var class="var">map</var>) in order.
</p>
<p>Multi-dimensional indexed images (of size MxNx3xK) are also
supported, both via a single input (<var class="var">rgb</var>) or its three color channels
as separate variables.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFind2rgb">ind2rgb</a>, <a class="ref" href="Color-Conversion.html#XREFrgb2hsv">rgb2hsv</a>, <a class="ref" href="Color-Conversion.html#XREFrgb2gray">rgb2gray</a>.
</p></dd></dl>
<a class="anchor" id="XREFind2rgb"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-ind2rgb"><span><code class="def-type"><var class="var">rgb</var> =</code> <strong class="def-name">ind2rgb</strong> <code class="def-code-arguments">(<var class="var">x</var>, <var class="var">map</var>)</code><a class="copiable-link" href="#index-ind2rgb"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-ind2rgb-1"><span><code class="def-type">[<var class="var">R</var>, <var class="var">G</var>, <var class="var">B</var>] =</code> <strong class="def-name">ind2rgb</strong> <code class="def-code-arguments">(<var class="var">x</var>, <var class="var">map</var>)</code><a class="copiable-link" href="#index-ind2rgb-1"> ¶</a></span></dt>
<dd><p>Convert an indexed image to red, green, and blue color components.
</p>
<p>The image <var class="var">x</var> must be an indexed image which will be converted using the
colormap <var class="var">map</var>. If <var class="var">map</var> does not contain enough colors for the
image, pixels in <var class="var">x</var> outside the range are mapped to the last color in
the map.
</p>
<p>The output may be a single RGB image (MxNx3 matrix where M and N
are the original image <var class="var">x</var> dimensions, one for each of the red, green
and blue channels). Alternatively, the individual red, green, and blue
color matrices of size MxN may be returned.
</p>
<p>Multi-dimensional indexed images (of size MxNx1xK) are also
supported.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFrgb2ind">rgb2ind</a>, <a class="ref" href="#XREFind2gray">ind2gray</a>, <a class="ref" href="Color-Conversion.html#XREFhsv2rgb">hsv2rgb</a>.
</p></dd></dl>
<p>Octave also provides tools to produce and work with movie frame structures.
Those structures encapsulate the image data (<code class="code">"cdata"</code> field) together
with the corresponding colormap (<code class="code">"colormap"</code> field).
</p>
<a class="anchor" id="XREFgetframe"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-getframe"><span><code class="def-type"><var class="var">frame</var> =</code> <strong class="def-name">getframe</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-getframe"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-getframe-1"><span><code class="def-type"><var class="var">frame</var> =</code> <strong class="def-name">getframe</strong> <code class="def-code-arguments">(<var class="var">hax</var>)</code><a class="copiable-link" href="#index-getframe-1"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-getframe-2"><span><code class="def-type"><var class="var">frame</var> =</code> <strong class="def-name">getframe</strong> <code class="def-code-arguments">(<var class="var">hfig</var>)</code><a class="copiable-link" href="#index-getframe-2"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-getframe-3"><span><code class="def-type"><var class="var">frame</var> =</code> <strong class="def-name">getframe</strong> <code class="def-code-arguments">(…, <var class="var">rect</var>)</code><a class="copiable-link" href="#index-getframe-3"> ¶</a></span></dt>
<dd>
<p>Capture a figure or axes as a movie frame structure.
</p>
<p>Without an argument, capture the current axes excluding ticklabels, title,
and x/y/zlabels. The returned structure <var class="var">frame</var> has a field
<code class="code">cdata</code>, which contains the actual image data in the form of an
NxMx3 (RGB) uint8 matrix in physical screen pixels, and a field
<code class="code">colormap</code> which is provided for <small class="sc">MATLAB</small> compatibility but is
always empty.
</p>
<p>If the first argument <var class="var">hax</var> is an axes handle, then capture this axes,
rather than the current axes returned by <code class="code">gca</code>.
</p>
<p>If the first argument <var class="var">hfig</var> is a figure handle then the entire
corresponding figure canvas is captured.
</p>
<p>Finally, if a second argument <var class="var">rect</var> is provided it must be a
four-element vector ([left bottom width height]) defining the region inside
the figure to be captured. Regardless of the figure <code class="code">"units"</code>
property, <var class="var">rect</var> must be defined in <strong class="strong">pixels</strong>.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFim2frame">im2frame</a>, <a class="ref" href="#XREFframe2im">frame2im</a>, <a class="ref" href="#XREFmovie">movie</a>.
</p></dd></dl>
<a class="anchor" id="XREFmovie"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-movie"><span><strong class="def-name">movie</strong> <code class="def-code-arguments">(<var class="var">mov</var>)</code><a class="copiable-link" href="#index-movie"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-movie-1"><span><strong class="def-name">movie</strong> <code class="def-code-arguments">(<var class="var">mov</var>, <var class="var">n</var>)</code><a class="copiable-link" href="#index-movie-1"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-movie-2"><span><strong class="def-name">movie</strong> <code class="def-code-arguments">(<var class="var">mov</var>, <var class="var">n</var>, <var class="var">fps</var>)</code><a class="copiable-link" href="#index-movie-2"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-movie-3"><span><strong class="def-name">movie</strong> <code class="def-code-arguments">(<var class="var">h</var>, …)</code><a class="copiable-link" href="#index-movie-3"> ¶</a></span></dt>
<dd><p>Play a movie defined by an array of frame structures.
</p>
<p>The movie <var class="var">mov</var> must be a struct array of frames with fields
<code class="code">"cdata"</code> and <code class="code">"colormap"</code>, as returned by the <code class="code">getframe</code>
function. By default all images are displayed once, at 12 fps, in the
current axes.
</p>
<p>The optional argument <var class="var">n</var> is a scalar or vector of integers that
controls the number of times the movie is displayed and which particular
frames are shown:
</p>
<dl class="table">
<dt>First element:</dt>
<dd>
<dl class="table">
<dt><var class="var">n</var>(1) > 0</dt>
<dd><p>Play the movie <var class="var">n</var>(1) times.
</p>
</dd>
<dt><var class="var">n</var>(1) < 0</dt>
<dd><p>Play the movie <code class="code">abs (<var class="var">n</var>(1)</code> times alternatively in forward and
backward order.
</p></dd>
</dl>
</dd>
<dt>Other elements (if any):</dt>
<dd><p>Indices of the frames in <var class="var">mov</var> that will be displayed.
</p></dd>
</dl>
<p>If the first argument is a handle to a figure or axes <var class="var">h</var>, the movie is
played in that figure or axes instead of the current axes.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFgetframe">getframe</a>, <a class="ref" href="#XREFim2frame">im2frame</a>, <a class="ref" href="#XREFframe2im">frame2im</a>.
</p></dd></dl>
<a class="anchor" id="XREFframe2im"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-frame2im"><span><code class="def-type">[<var class="var">x</var>, <var class="var">map</var>] =</code> <strong class="def-name">frame2im</strong> <code class="def-code-arguments">(<var class="var">frame</var>)</code><a class="copiable-link" href="#index-frame2im"> ¶</a></span></dt>
<dd><p>Convert movie frame to indexed image.
</p>
<p>A movie frame is simply a struct with the fields <code class="code">"cdata"</code> and
<code class="code">"colormap"</code>.
</p>
<p>Support for N-dimensional images or movies is given when <var class="var">frame</var> is a
struct array. In such cases, <var class="var">x</var> will be a MxNx1xK or MxNx3xK
for indexed and RGB movies respectively, with each frame concatenated
along the 4th dimension.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFim2frame">im2frame</a>, <a class="ref" href="#XREFgetframe">getframe</a>.
</p></dd></dl>
<a class="anchor" id="XREFim2frame"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-im2frame"><span><code class="def-type"><var class="var">frame</var> =</code> <strong class="def-name">im2frame</strong> <code class="def-code-arguments">(<var class="var">rgb</var>)</code><a class="copiable-link" href="#index-im2frame"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-im2frame-1"><span><code class="def-type"><var class="var">frame</var> =</code> <strong class="def-name">im2frame</strong> <code class="def-code-arguments">(<var class="var">x</var>, <var class="var">map</var>)</code><a class="copiable-link" href="#index-im2frame-1"> ¶</a></span></dt>
<dd><p>Convert image to movie frame.
</p>
<p>A movie frame is simply a struct with the fields <code class="code">"cdata"</code> and
<code class="code">"colormap"</code>.
</p>
<p>Support for N-dimensional images is given when each image projection,
matrix sizes of MxN and MxNx3 for RGB images, is concatenated
along the fourth dimension. In such cases, the returned value is a struct
array.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFframe2im">frame2im</a>.
</p></dd></dl>
<p>The <code class="code">colormap</code> function is used to change the colormap of the current
axes or figure.
</p>
<a class="anchor" id="XREFcolormap"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-colormap"><span><code class="def-type"><var class="var">cmap</var> =</code> <strong class="def-name">colormap</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-colormap"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-colormap-1"><span><code class="def-type"><var class="var">cmap</var> =</code> <strong class="def-name">colormap</strong> <code class="def-code-arguments">(<var class="var">map</var>)</code><a class="copiable-link" href="#index-colormap-1"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-colormap-2"><span><code class="def-type"><var class="var">cmap</var> =</code> <strong class="def-name">colormap</strong> <code class="def-code-arguments">(<code class="code">"default"</code>)</code><a class="copiable-link" href="#index-colormap-2"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-colormap-3"><span><code class="def-type"><var class="var">cmap</var> =</code> <strong class="def-name">colormap</strong> <code class="def-code-arguments">(<var class="var">map_name</var>)</code><a class="copiable-link" href="#index-colormap-3"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-colormap-4"><span><code class="def-type"><var class="var">cmap</var> =</code> <strong class="def-name">colormap</strong> <code class="def-code-arguments">(<var class="var">hax</var>, …)</code><a class="copiable-link" href="#index-colormap-4"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-colormap-5"><span><code class="def-type"><var class="var">cmap</var> =</code> <strong class="def-name">colormap</strong> <code class="def-code-arguments">(<var class="var">hfig</var>, …)</code><a class="copiable-link" href="#index-colormap-5"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-colormap-6"><span><strong class="def-name">colormap</strong> <code class="def-code-arguments"><var class="var">map_name</var></code><a class="copiable-link" href="#index-colormap-6"> ¶</a></span></dt>
<dd><p>Query or set the current colormap.
</p>
<p>With no input arguments, <code class="code">colormap</code> returns the current color map. If
there is no current figure, a new figure will be opened and the default
color map will be returned.
</p>
<p><code class="code">colormap (<var class="var">map</var>)</code> sets the current colormap to <var class="var">map</var>. The
colormap should be an <var class="var">n</var> row by 3 column matrix. The columns
contain red, green, and blue intensities respectively. All entries
must be between 0 and 1 inclusive. The new colormap is returned.
</p>
<p><code class="code">colormap (<code class="code">"default"</code>)</code> restores the default colormap (the
<code class="code">viridis</code> map with 256 entries). The default colormap is returned.
</p>
<p>The map may also be specified by a string, <var class="var">map_name</var>, which
is the name of a function that returns a colormap.
</p>
<p>If the first argument <var class="var">hax</var> is an axes handle, then the colormap for
the specified axes is queried or set. If the first argument <var class="var">hfig</var> is a
figure handle, then the colormap for the specified figure is queried or set.
</p>
<p>For convenience, it is also possible to use this function with the
command form, <code class="code">colormap <var class="var">map_name</var></code>.
</p>
<p>The list of built-in colormaps is:
</p>
<table class="multitable">
<thead><tr><th width="15%">Map</th><th width="85%">Description</th></tr></thead>
<tbody><tr><td width="15%">viridis</td><td width="85%">default</td></tr>
<tr><td width="15%">turbo</td><td width="85%">colormap traversing blue, cyan, green, yellow, red; modern replacement for jet.</td></tr>
<tr><td width="15%">jet</td><td width="85%">colormap traversing blue, cyan, green, yellow, red.</td></tr>
<tr><td width="15%">cubehelix</td><td width="85%">colormap traversing black, blue, green, red, white with increasing intensity.</td></tr>
<tr><td width="15%">hsv</td><td width="85%">cyclic colormap traversing Hue, Saturation, Value space.</td></tr>
<tr><td width="15%">rainbow</td><td width="85%">colormap traversing red, yellow, blue, green, violet.</td></tr>
<tr><td width="15%">————-</td><td width="85%">———————————————————————————————</td></tr>
<tr><td width="15%">hot</td><td width="85%">colormap traversing black, red, orange, yellow, white.</td></tr>
<tr><td width="15%">cool</td><td width="85%">colormap traversing cyan, purple, magenta.</td></tr>
<tr><td width="15%">spring</td><td width="85%">colormap traversing magenta to yellow.</td></tr>
<tr><td width="15%">summer</td><td width="85%">colormap traversing green to yellow.</td></tr>
<tr><td width="15%">autumn</td><td width="85%">colormap traversing red, orange, yellow.</td></tr>
<tr><td width="15%">winter</td><td width="85%">colormap traversing blue to green.</td></tr>
<tr><td width="15%">————-</td><td width="85%">———————————————————————————————</td></tr>
<tr><td width="15%">gray</td><td width="85%">colormap traversing black to white in shades of gray.</td></tr>
<tr><td width="15%">bone</td><td width="85%">colormap traversing black, gray-blue, white.</td></tr>
<tr><td width="15%">copper</td><td width="85%">colormap traversing black to light copper.</td></tr>
<tr><td width="15%">pink</td><td width="85%">colormap traversing black, gray-pink, white.</td></tr>
<tr><td width="15%">ocean</td><td width="85%">colormap traversing black, dark-blue, white.</td></tr>
<tr><td width="15%">————-</td><td width="85%">———————————————————————————————</td></tr>
<tr><td width="15%">colorcube</td><td width="85%">equally spaced colors in RGB color space.</td></tr>
<tr><td width="15%">flag</td><td width="85%">cyclic 4-color map of red, white, blue, black.</td></tr>
<tr><td width="15%">lines</td><td width="85%">cyclic colormap with colors from axes <code class="code">"ColorOrder"</code> property.</td></tr>
<tr><td width="15%">prism</td><td width="85%">cyclic 6-color map of red, orange, yellow, green, blue, violet.</td></tr>
<tr><td width="15%">————-</td><td width="85%">———————————————————————————————</td></tr>
<tr><td width="15%">white</td><td width="85%">all white colormap (no colors).</td></tr>
</tbody>
</table>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFviridis">viridis</a>, <a class="ref" href="#XREFturbo">turbo</a>, <a class="ref" href="#XREFjet">jet</a>, <a class="ref" href="#XREFcubehelix">cubehelix</a>, <a class="ref" href="#XREFhsv">hsv</a>, <a class="ref" href="#XREFrainbow">rainbow</a>, <a class="ref" href="#XREFhot">hot</a>, <a class="ref" href="#XREFcool">cool</a>, <a class="ref" href="#XREFspring">spring</a>, <a class="ref" href="#XREFsummer">summer</a>, <a class="ref" href="#XREFautumn">autumn</a>, <a class="ref" href="#XREFwinter">winter</a>, <a class="ref" href="#XREFgray">gray</a>, <a class="ref" href="#XREFbone">bone</a>, <a class="ref" href="#XREFcopper">copper</a>, <a class="ref" href="#XREFpink">pink</a>, <a class="ref" href="#XREFocean">ocean</a>, <a class="ref" href="#XREFcolorcube">colorcube</a>, <a class="ref" href="#XREFflag">flag</a>, <a class="ref" href="#XREFlines">lines</a>, <a class="ref" href="#XREFprism">prism</a>, <a class="ref" href="#XREFwhite">white</a>.
</p></dd></dl>
<a class="anchor" id="XREFiscolormap"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-iscolormap"><span><code class="def-type"><var class="var">tf</var> =</code> <strong class="def-name">iscolormap</strong> <code class="def-code-arguments">(<var class="var">cmap</var>)</code><a class="copiable-link" href="#index-iscolormap"> ¶</a></span></dt>
<dd><p>Return true if <var class="var">cmap</var> is a colormap.
</p>
<p>A colormap is a real matrix, of class single or double, with 3 columns.
Each row represents a single color. The 3 columns contain red, green,
and blue intensities respectively.
</p>
<p>All values in a colormap should be in the [0 1] range but this is not
enforced. Each function must decide what to do for values outside this
range.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFcolormap">colormap</a>, <a class="ref" href="#XREFrgbplot">rgbplot</a>.
</p></dd></dl>
<p>The following functions return predefined colormaps, the same that can be
requested by name using the <code class="code">colormap</code> function.
</p>
<a class="anchor" id="XREFrgbplot"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-rgbplot"><span><strong class="def-name">rgbplot</strong> <code class="def-code-arguments">(<var class="var">cmap</var>)</code><a class="copiable-link" href="#index-rgbplot"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-rgbplot-1"><span><strong class="def-name">rgbplot</strong> <code class="def-code-arguments">(<var class="var">cmap</var>, <var class="var">style</var>)</code><a class="copiable-link" href="#index-rgbplot-1"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-rgbplot-2"><span><code class="def-type"><var class="var">h</var> =</code> <strong class="def-name">rgbplot</strong> <code class="def-code-arguments">(…)</code><a class="copiable-link" href="#index-rgbplot-2"> ¶</a></span></dt>
<dd><p>Plot the components of a colormap.
</p>
<p>Two different <var class="var">style</var>s are available for displaying the <var class="var">cmap</var>:
</p>
<dl class="table">
<dt>profile (default)</dt>
<dd><p>Plot the RGB line profile of the colormap for each of the channels (red,
green and blue) with the plot lines colored appropriately. Each line
represents the intensity of an RGB component across the colormap.
</p>
</dd>
<dt>composite</dt>
<dd><p>Draw the colormap across the X-axis so that the actual index colors are
visible rather than the individual color components.
</p>
</dd>
</dl>
<p>The optional return value <var class="var">h</var> is a graphics handle to the created plot.
</p>
<p>Run <code class="code">demo rgbplot</code> to see an example of <code class="code">rgbplot</code> and each style
option.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFcolormap">colormap</a>.
</p></dd></dl>
<a class="anchor" id="XREFautumn"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-autumn"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">autumn</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-autumn"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-autumn-1"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">autumn</strong> <code class="def-code-arguments">(<var class="var">n</var>)</code><a class="copiable-link" href="#index-autumn-1"> ¶</a></span></dt>
<dd><p>Create color colormap.
This colormap ranges from red through orange to yellow.
</p>
<p>The argument <var class="var">n</var> must be a scalar.
If <var class="var">n</var> is not specified the length of the current colormap is used. If
there is no current colormap the default value of 256 is used.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFcolormap">colormap</a>.
</p></dd></dl>
<a class="anchor" id="XREFbone"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-bone"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">bone</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-bone"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-bone-1"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">bone</strong> <code class="def-code-arguments">(<var class="var">n</var>)</code><a class="copiable-link" href="#index-bone-1"> ¶</a></span></dt>
<dd><p>Create color colormap. This colormap varies from black to white with
gray-blue shades.
</p>
<p>The argument <var class="var">n</var> must be a scalar.
If <var class="var">n</var> is not specified the length of the current colormap is used. If
there is no current colormap the default value of 256 is used.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFcolormap">colormap</a>.
</p></dd></dl>
<a class="anchor" id="XREFcolorcube"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-colorcube"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">colorcube</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-colorcube"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-colorcube-1"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">colorcube</strong> <code class="def-code-arguments">(<var class="var">n</var>)</code><a class="copiable-link" href="#index-colorcube-1"> ¶</a></span></dt>
<dd><p>Create color colormap. This colormap is composed of as many equally
spaced colors (not grays) in the RGB color space as possible.
</p>
<p>If there are not a perfect number <var class="var">n</var> of regularly spaced colors then
the remaining entries in the colormap are gradients of pure red, green,
blue, and gray.
</p>
<p>The argument <var class="var">n</var> must be a scalar.
If <var class="var">n</var> is not specified the length of the current colormap is used. If
there is no current colormap the default value of 256 is used.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFcolormap">colormap</a>.
</p></dd></dl>
<a class="anchor" id="XREFcool"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-cool"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">cool</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-cool"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-cool-1"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">cool</strong> <code class="def-code-arguments">(<var class="var">n</var>)</code><a class="copiable-link" href="#index-cool-1"> ¶</a></span></dt>
<dd><p>Create color colormap. The colormap varies from cyan to magenta.
</p>
<p>The argument <var class="var">n</var> must be a scalar.
If <var class="var">n</var> is not specified the length of the current colormap is used. If
there is no current colormap the default value of 256 is used.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFcolormap">colormap</a>.
</p></dd></dl>
<a class="anchor" id="XREFcopper"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-copper"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">copper</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-copper"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-copper-1"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">copper</strong> <code class="def-code-arguments">(<var class="var">n</var>)</code><a class="copiable-link" href="#index-copper-1"> ¶</a></span></dt>
<dd><p>Create color colormap. This colormap varies from black to a light copper
tone.
</p>
<p>The argument <var class="var">n</var> must be a scalar.
If <var class="var">n</var> is not specified the length of the current colormap is used. If
there is no current colormap the default value of 256 is used.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFcolormap">colormap</a>.
</p></dd></dl>
<a class="anchor" id="XREFcubehelix"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-cubehelix"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">cubehelix</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-cubehelix"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-cubehelix-1"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">cubehelix</strong> <code class="def-code-arguments">(<var class="var">n</var>)</code><a class="copiable-link" href="#index-cubehelix-1"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-cubehelix-2"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">cubehelix</strong> <code class="def-code-arguments">(<var class="var">n</var>, <var class="var">start</var>, <var class="var">rots</var>, <var class="var">hue</var>, <var class="var">gamma</var>)</code><a class="copiable-link" href="#index-cubehelix-2"> ¶</a></span></dt>
<dd><p>Create cubehelix colormap.
</p>
<p>This colormap varies from black to white going though blue, green, and red
tones while maintaining a monotonically increasing perception of intensity.
This is achieved by traversing a color cube from black to white through
a helix, hence the name cubehelix, while taking into account the perceived
brightness of each channel according to the NTSC specifications from 1953.
</p>
<div class="example">
<pre class="example-preformatted">rgbplot (cubehelix (256))
</pre></div>
<p>The argument <var class="var">n</var> must be a scalar.
If <var class="var">n</var> is not specified the length of the current colormap is used. If
there is no current colormap the default value of 256 is used.
</p>
<p>Reference: Green, D. A., 2011,
<cite class="cite">A colour scheme for the display of astronomical intensity
images</cite>, Bulletin of the Astronomical Society of India, 39, 289.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFcolormap">colormap</a>.
</p></dd></dl>
<a class="anchor" id="XREFflag"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-flag"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">flag</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-flag"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-flag-1"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">flag</strong> <code class="def-code-arguments">(<var class="var">n</var>)</code><a class="copiable-link" href="#index-flag-1"> ¶</a></span></dt>
<dd><p>Create color colormap. This colormap cycles through red, white, blue, and
black with each index change.
</p>
<p>The argument <var class="var">n</var> must be a scalar.
If <var class="var">n</var> is not specified the length of the current colormap is used. If
there is no current colormap the default value of 256 is used.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFcolormap">colormap</a>.
</p></dd></dl>
<a class="anchor" id="XREFgray"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-gray"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">gray</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-gray"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-gray-1"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">gray</strong> <code class="def-code-arguments">(<var class="var">n</var>)</code><a class="copiable-link" href="#index-gray-1"> ¶</a></span></dt>
<dd><p>Create gray colormap. This colormap varies from black to white with shades
of gray.
</p>
<p>The argument <var class="var">n</var> must be a scalar.
If <var class="var">n</var> is not specified the length of the current colormap is used. If
there is no current colormap the default value of 256 is used.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFcolormap">colormap</a>.
</p></dd></dl>
<a class="anchor" id="XREFhot"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-hot"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">hot</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-hot"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-hot-1"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">hot</strong> <code class="def-code-arguments">(<var class="var">n</var>)</code><a class="copiable-link" href="#index-hot-1"> ¶</a></span></dt>
<dd><p>Create color colormap. This colormap ranges from black through dark red,
red, orange, yellow, to white.
</p>
<p>The argument <var class="var">n</var> must be a scalar.
If <var class="var">n</var> is not specified the length of the current colormap is used. If
there is no current colormap the default value of 256 is used.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFcolormap">colormap</a>.
</p></dd></dl>
<a class="anchor" id="XREFhsv"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-hsv"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">hsv</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-hsv"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-hsv-1"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">hsv</strong> <code class="def-code-arguments">(<var class="var">n</var>)</code><a class="copiable-link" href="#index-hsv-1"> ¶</a></span></dt>
<dd><p>Create color colormap. This colormap begins with red, changes through
yellow, green, cyan, blue, and magenta, before returning to red.
</p>
<p>It is useful for displaying periodic functions. The map is obtained by
linearly varying the hue through all possible values while keeping constant
maximum saturation and value. The equivalent code is
<code class="code">hsv2rgb ([(0:N-1)'/N, ones(N,2)])</code>.
</p>
<p>The argument <var class="var">n</var> must be a scalar.
If <var class="var">n</var> is not specified the length of the current colormap is used. If
there is no current colormap the default value of 256 is used.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFcolormap">colormap</a>.
</p></dd></dl>
<a class="anchor" id="XREFjet"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-jet"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">jet</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-jet"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-jet-1"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">jet</strong> <code class="def-code-arguments">(<var class="var">n</var>)</code><a class="copiable-link" href="#index-jet-1"> ¶</a></span></dt>
<dd><p>Create color colormap. This colormap ranges from dark blue through blue,
cyan, green, yellow, red, to dark red.
</p>
<p>The argument <var class="var">n</var> must be a scalar.
If <var class="var">n</var> is not specified the length of the current colormap is used. If
there is no current colormap the default value of 256 is used.
</p>
<p>Programming Note: The <code class="code">jet</code> colormap is not perceptually uniform.
Try the <code class="code">viridis</code> colormap if that is important. For a drop-in
replacement for <code class="code">jet</code> with better perceptual characteristics try
the <code class="code">turbo</code> colormap.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFcolormap">colormap</a>, <a class="ref" href="#XREFturbo">turbo</a>.
</p></dd></dl>
<a class="anchor" id="XREFlines"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-lines"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">lines</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-lines"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-lines-1"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">lines</strong> <code class="def-code-arguments">(<var class="var">n</var>)</code><a class="copiable-link" href="#index-lines-1"> ¶</a></span></dt>
<dd><p>Create color colormap. This colormap is composed of the list of colors
in the current axes <code class="code">"ColorOrder"</code> property. The default is blue,
orange, yellow, purple, green, light blue, and dark red.
</p>
<p>The argument <var class="var">n</var> must be a scalar.
If <var class="var">n</var> is not specified the length of the current colormap is used. If
there is no current colormap the default value of 256 is used.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFcolormap">colormap</a>.
</p></dd></dl>
<a class="anchor" id="XREFocean"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-ocean"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">ocean</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-ocean"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-ocean-1"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">ocean</strong> <code class="def-code-arguments">(<var class="var">n</var>)</code><a class="copiable-link" href="#index-ocean-1"> ¶</a></span></dt>
<dd><p>Create color colormap. This colormap varies from black to white with shades
of blue.
</p>
<p>The argument <var class="var">n</var> must be a scalar.
If <var class="var">n</var> is not specified the length of the current colormap is used. If
there is no current colormap the default value of 256 is used.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFcolormap">colormap</a>.
</p></dd></dl>
<a class="anchor" id="XREFpink"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-pink"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">pink</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-pink"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-pink-1"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">pink</strong> <code class="def-code-arguments">(<var class="var">n</var>)</code><a class="copiable-link" href="#index-pink-1"> ¶</a></span></dt>
<dd><p>Create color colormap. This colormap varies from black to white with
shades of gray-pink.
</p>
<p>This colormap gives a sepia tone when used on grayscale images.
</p>
<p>The argument <var class="var">n</var> must be a scalar.
If <var class="var">n</var> is not specified the length of the current colormap is used. If
there is no current colormap the default value of 256 is used.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFcolormap">colormap</a>.
</p></dd></dl>
<a class="anchor" id="XREFprism"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-prism"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">prism</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-prism"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-prism-1"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">prism</strong> <code class="def-code-arguments">(<var class="var">n</var>)</code><a class="copiable-link" href="#index-prism-1"> ¶</a></span></dt>
<dd><p>Create color colormap. This colormap cycles through red, orange, yellow,
green, blue and violet with each index change.
</p>
<p>The argument <var class="var">n</var> must be a scalar.
If <var class="var">n</var> is not specified the length of the current colormap is used. If
there is no current colormap the default value of 256 is used.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFcolormap">colormap</a>.
</p></dd></dl>
<a class="anchor" id="XREFrainbow"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-rainbow"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">rainbow</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-rainbow"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-rainbow-1"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">rainbow</strong> <code class="def-code-arguments">(<var class="var">n</var>)</code><a class="copiable-link" href="#index-rainbow-1"> ¶</a></span></dt>
<dd><p>Create color colormap. This colormap ranges from red through orange,
yellow, green, blue, to violet.
</p>
<p>The argument <var class="var">n</var> must be a scalar.
If <var class="var">n</var> is not specified the length of the current colormap is used. If
there is no current colormap the default value of 256 is used.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFcolormap">colormap</a>.
</p></dd></dl>
<a class="anchor" id="XREFspring"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-spring"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">spring</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-spring"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-spring-1"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">spring</strong> <code class="def-code-arguments">(<var class="var">n</var>)</code><a class="copiable-link" href="#index-spring-1"> ¶</a></span></dt>
<dd><p>Create color colormap. This colormap varies from magenta to yellow.
</p>
<p>The argument <var class="var">n</var> must be a scalar.
If <var class="var">n</var> is not specified the length of the current colormap is used. If
there is no current colormap the default value of 256 is used.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFcolormap">colormap</a>.
</p></dd></dl>
<a class="anchor" id="XREFsummer"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-summer"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">summer</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-summer"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-summer-1"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">summer</strong> <code class="def-code-arguments">(<var class="var">n</var>)</code><a class="copiable-link" href="#index-summer-1"> ¶</a></span></dt>
<dd><p>Create color colormap. This colormap varies from green to yellow.
</p>
<p>The argument <var class="var">n</var> must be a scalar.
If <var class="var">n</var> is not specified the length of the current colormap is used. If
there is no current colormap the default value of 256 is used.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFcolormap">colormap</a>.
</p></dd></dl>
<a class="anchor" id="XREFturbo"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-turbo"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">turbo</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-turbo"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-turbo-1"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">turbo</strong> <code class="def-code-arguments">(<var class="var">n</var>)</code><a class="copiable-link" href="#index-turbo-1"> ¶</a></span></dt>
<dd><p>Create color colormap. This colormap ranges from dark blue through green
to dark red; similar to the outdated <code class="code">jet</code> colormap but perceptually
uniform.
</p>
<p>The argument <var class="var">n</var> must be a scalar.
If <var class="var">n</var> is not specified the length of the current colormap is used. If
there is no current colormap the default value of 256 is used.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFcolormap">colormap</a>.
</p></dd></dl>
<a class="anchor" id="XREFviridis"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-viridis"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">viridis</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-viridis"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-viridis-1"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">viridis</strong> <code class="def-code-arguments">(<var class="var">n</var>)</code><a class="copiable-link" href="#index-viridis-1"> ¶</a></span></dt>
<dd><p>Create color colormap. This colormap ranges from dark purplish-blue through
blue, green, to yellow.
</p>
<p>The argument <var class="var">n</var> must be a scalar.
If <var class="var">n</var> is not specified the length of the current colormap is used. If
there is no current colormap the default value of 256 is used.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFcolormap">colormap</a>.
</p></dd></dl>
<a class="anchor" id="XREFwhite"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-white"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">white</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-white"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-white-1"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">white</strong> <code class="def-code-arguments">(<var class="var">n</var>)</code><a class="copiable-link" href="#index-white-1"> ¶</a></span></dt>
<dd><p>Create color colormap. This colormap is completely white.
</p>
<p>The argument <var class="var">n</var> must be a scalar.
If <var class="var">n</var> is not specified the length of the current colormap is used. If
there is no current colormap the default value of 256 is used.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFcolormap">colormap</a>.
</p></dd></dl>
<a class="anchor" id="XREFwinter"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-winter"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">winter</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-winter"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-winter-1"><span><code class="def-type"><var class="var">map</var> =</code> <strong class="def-name">winter</strong> <code class="def-code-arguments">(<var class="var">n</var>)</code><a class="copiable-link" href="#index-winter-1"> ¶</a></span></dt>
<dd><p>Create color colormap. This colormap varies from blue to green.
</p>
<p>The argument <var class="var">n</var> must be a scalar.
If <var class="var">n</var> is not specified the length of the current colormap is used. If
there is no current colormap the default value of 256 is used.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFcolormap">colormap</a>.
</p></dd></dl>
<a class="anchor" id="XREFcontrast"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-contrast"><span><code class="def-type"><var class="var">cmap</var> =</code> <strong class="def-name">contrast</strong> <code class="def-code-arguments">(<var class="var">x</var>)</code><a class="copiable-link" href="#index-contrast"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-contrast-1"><span><code class="def-type"><var class="var">cmap</var> =</code> <strong class="def-name">contrast</strong> <code class="def-code-arguments">(<var class="var">x</var>, <var class="var">n</var>)</code><a class="copiable-link" href="#index-contrast-1"> ¶</a></span></dt>
<dd><p>Return a gray colormap that maximizes the contrast in an image.
</p>
<p>The returned colormap will have <var class="var">n</var> rows. If <var class="var">n</var> is not defined
then the size of the current colormap is used.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFcolormap">colormap</a>, <a class="ref" href="#XREFbrighten">brighten</a>.
</p></dd></dl>
<p>The following three functions modify the existing colormap rather than
replace it.
</p>
<a class="anchor" id="XREFbrighten"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-brighten"><span><code class="def-type"><var class="var">map_out</var> =</code> <strong class="def-name">brighten</strong> <code class="def-code-arguments">(<var class="var">beta</var>)</code><a class="copiable-link" href="#index-brighten"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-brighten-1"><span><code class="def-type"><var class="var">map_out</var> =</code> <strong class="def-name">brighten</strong> <code class="def-code-arguments">(<var class="var">map</var>, <var class="var">beta</var>)</code><a class="copiable-link" href="#index-brighten-1"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-brighten-2"><span><code class="def-type"><var class="var">map_out</var> =</code> <strong class="def-name">brighten</strong> <code class="def-code-arguments">(<var class="var">h</var>, <var class="var">beta</var>)</code><a class="copiable-link" href="#index-brighten-2"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-brighten-3"><span><strong class="def-name">brighten</strong> <code class="def-code-arguments">(…)</code><a class="copiable-link" href="#index-brighten-3"> ¶</a></span></dt>
<dd><p>Brighten or darken a colormap.
</p>
<p>The argument <var class="var">beta</var> must be a scalar between -1 and 1, where a negative
value darkens and a positive value brightens the colormap.
</p>
<p>If the <var class="var">map</var> argument is omitted, the function is applied to the current
colormap.
</p>
<p>The first argument can also be a valid graphics handle <var class="var">h</var>, in which
case <code class="code">brighten</code> is applied to the colormap associated with this handle.
</p>
<p>If no output is specified then the result is written to the current
colormap.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFcolormap">colormap</a>, <a class="ref" href="#XREFcontrast">contrast</a>.
</p></dd></dl>
<a class="anchor" id="XREFspinmap"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-spinmap"><span><strong class="def-name">spinmap</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-spinmap"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-spinmap-1"><span><strong class="def-name">spinmap</strong> <code class="def-code-arguments">(<var class="var">t</var>)</code><a class="copiable-link" href="#index-spinmap-1"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-spinmap-2"><span><strong class="def-name">spinmap</strong> <code class="def-code-arguments">(<var class="var">t</var>, <var class="var">inc</var>)</code><a class="copiable-link" href="#index-spinmap-2"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-spinmap-3"><span><strong class="def-name">spinmap</strong> <code class="def-code-arguments">("inf")</code><a class="copiable-link" href="#index-spinmap-3"> ¶</a></span></dt>
<dd><p>Cycle the colormap for <var class="var">t</var> seconds with a color increment of <var class="var">inc</var>.
</p>
<p>Both parameters are optional. The default cycle time is 5 seconds and the
default increment is 2. If the option <code class="code">"inf"</code> is given then cycle
continuously until <kbd class="kbd">Control-C</kbd> is pressed.
</p>
<p>When rotating, the original color 1 becomes color 2, color 2 becomes
color 3, etc. A positive or negative increment is allowed and a higher
value of <var class="var">inc</var> will cause faster cycling through the colormap.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFcolormap">colormap</a>.
</p></dd></dl>
<a class="anchor" id="XREFwhitebg"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-whitebg"><span><strong class="def-name">whitebg</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-whitebg"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-whitebg-1"><span><strong class="def-name">whitebg</strong> <code class="def-code-arguments">(<var class="var">color</var>)</code><a class="copiable-link" href="#index-whitebg-1"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-whitebg-2"><span><strong class="def-name">whitebg</strong> <code class="def-code-arguments">("none")</code><a class="copiable-link" href="#index-whitebg-2"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-whitebg-3"><span><strong class="def-name">whitebg</strong> <code class="def-code-arguments">(<var class="var">hfig</var>)</code><a class="copiable-link" href="#index-whitebg-3"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-whitebg-4"><span><strong class="def-name">whitebg</strong> <code class="def-code-arguments">(<var class="var">hfig</var>, <var class="var">color</var>)</code><a class="copiable-link" href="#index-whitebg-4"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-whitebg-5"><span><strong class="def-name">whitebg</strong> <code class="def-code-arguments">(<var class="var">hfig</var>, "none")</code><a class="copiable-link" href="#index-whitebg-5"> ¶</a></span></dt>
<dd><p>Invert the colors in the current color scheme.
</p>
<p>The root properties are also inverted such that all subsequent plots will
use the new color scheme.
</p>
<p>If the optional argument <var class="var">color</var> is present then the background color
is set to <var class="var">color</var> rather than inverted. <var class="var">color</var> may be a string
representing one of the eight known colors or an RGB triplet. The special
string argument <code class="code">"none"</code> restores the plot to the factory default
colors.
</p>
<p>If the first argument <var class="var">hfig</var> is a figure handle or list of figure
handles, then operate on these figures rather than the current figure
returned by <code class="code">gcf</code>. The root properties will not be changed unless 0
is in the list of figures.
</p>
<p>Programming Note: <code class="code">whitebg</code> operates by changing the color properties
of the children of the specified figures. Only objects with a single color
are affected. For example, a patch with a single <code class="code">"FaceColor"</code> will
be changed, but a patch with shading (<code class="code">"interp"</code>) will not be
modified. For inversion, the new color is simply the inversion in RGB
space: <code class="code"><var class="var">cnew</var> = [1-<var class="var">R</var> 1-<var class="var">G</var> 1-<var class="var">B</var>]</code>. When a color
is specified, the axes and figure are set to the new color, and the color
of child objects are then adjusted to have some contrast (visibility)
against the new background.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="Managing-Default-Properties.html#XREFreset">reset</a>, <a class="ref" href="Handle-Functions.html#XREFget">get</a>, <a class="ref" href="Handle-Functions.html#XREFset">set</a>.
</p></dd></dl>
<p>The following functions can be used to manipulate colormaps.
</p>
<a class="anchor" id="XREFcmunique"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-cmunique"><span><code class="def-type">[<var class="var">Y</var>, <var class="var">newmap</var>] =</code> <strong class="def-name">cmunique</strong> <code class="def-code-arguments">(<var class="var">X</var>, <var class="var">map</var>)</code><a class="copiable-link" href="#index-cmunique"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-cmunique-1"><span><code class="def-type">[<var class="var">Y</var>, <var class="var">newmap</var>] =</code> <strong class="def-name">cmunique</strong> <code class="def-code-arguments">(<var class="var">RGB</var>)</code><a class="copiable-link" href="#index-cmunique-1"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-cmunique-2"><span><code class="def-type">[<var class="var">Y</var>, <var class="var">newmap</var>] =</code> <strong class="def-name">cmunique</strong> <code class="def-code-arguments">(<var class="var">I</var>)</code><a class="copiable-link" href="#index-cmunique-2"> ¶</a></span></dt>
<dd><p>Convert an input image <var class="var">X</var> to an output indexed image <var class="var">Y</var> which uses
the smallest colormap possible <var class="var">newmap</var>.
</p>
<p>When the input is an indexed image (<var class="var">X</var> with colormap <var class="var">map</var>) the
output is a colormap <var class="var">newmap</var> from which any repeated rows have been
eliminated. The output image, <var class="var">Y</var>, is the original input image with
the indices adjusted to match the new, possibly smaller, colormap.
</p>
<p>When the input is an RGB image (an MxNx3 array), the output
colormap will contain one entry for every unique color in the original
image. In the worst case the new map could have as many rows as the
number of pixels in the original image.
</p>
<p>When the input is a grayscale image <var class="var">I</var>, the output colormap will
contain one entry for every unique intensity value in the original image.
In the worst case the new map could have as many rows as the number of
pixels in the original image.
</p>
<p>Implementation Details:
</p>
<p><var class="var">newmap</var> is always an Mx3 matrix, even if the input image is
an intensity grayscale image <var class="var">I</var> (all three RGB planes are
assigned the same value).
</p>
<p>The output image is of class uint8 if the size of the new colormap is
less than or equal to 256. Otherwise, the output image is of class double.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFrgb2ind">rgb2ind</a>, <a class="ref" href="#XREFgray2ind">gray2ind</a>.
</p></dd></dl>
<a class="anchor" id="XREFcmpermute"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-cmpermute"><span><code class="def-type">[<var class="var">Y</var>, <var class="var">newmap</var>] =</code> <strong class="def-name">cmpermute</strong> <code class="def-code-arguments">(<var class="var">X</var>, <var class="var">map</var>)</code><a class="copiable-link" href="#index-cmpermute"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-cmpermute-1"><span><code class="def-type">[<var class="var">Y</var>, <var class="var">newmap</var>] =</code> <strong class="def-name">cmpermute</strong> <code class="def-code-arguments">(<var class="var">X</var>, <var class="var">map</var>, <var class="var">index</var>)</code><a class="copiable-link" href="#index-cmpermute-1"> ¶</a></span></dt>
<dd><p>Reorder colors in a colormap.
</p>
<p>When called with only two arguments, <code class="code">cmpermute</code> randomly rearranges
the colormap <var class="var">map</var> and returns a new colormap <var class="var">newmap</var>. It also
returns the indexed image <var class="var">Y</var> which is the equivalent of the original
input image <var class="var">X</var> when displayed using <var class="var">newmap</var>.
</p>
<p>When called with an optional third argument the order of colors in the new
colormap is defined by <var class="var">index</var>.
</p>
<p><strong class="strong">Caution:</strong> <var class="var">index</var> should not have repeated elements or the
function will fail.
</p>
</dd></dl>
</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="Plotting-on-top-of-Images.html">Plotting on top of Images</a>, Previous: <a href="Displaying-Images.html">Displaying Images</a>, Up: <a href="Image-Processing.html">Image Processing</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>
|