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
|
<!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>Loading and Saving Images (GNU Octave (version 10.3.0))</title>
<meta name="description" content="Loading and Saving Images (GNU Octave (version 10.3.0))">
<meta name="keywords" content="Loading and Saving 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="Displaying-Images.html" rel="next" title="Displaying Images">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
div.example {margin-left: 3.2em}
pre.format-preformatted {font-family: inherit}
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="Loading-and-Saving-Images">
<div class="nav-panel">
<p>
Next: <a href="Displaying-Images.html" accesskey="n" rel="next">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="Loading-and-Saving-Images-1"><span>32.1 Loading and Saving Images<a class="copiable-link" href="#Loading-and-Saving-Images-1"> ¶</a></span></h3>
<p>The first step in most image processing tasks is to load an image
into Octave which is done with the <code class="code">imread</code> function.
The <code class="code">imwrite</code> function is the corresponding function
for writing images to the disk.
</p>
<p>In summary, most image processing code will follow the structure of this code
</p>
<div class="example">
<div class="group"><pre class="example-preformatted">I = imread ("my_input_image.img");
J = process_my_image (I);
imwrite (J, "my_output_image.img");
</pre></div></div>
<a class="anchor" id="XREFimread"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-imread"><span><code class="def-type">[<var class="var">img</var>, <var class="var">map</var>, <var class="var">alpha</var>] =</code> <strong class="def-name">imread</strong> <code class="def-code-arguments">(<var class="var">filename</var>)</code><a class="copiable-link" href="#index-imread"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-imread-1"><span><code class="def-type">[…] =</code> <strong class="def-name">imread</strong> <code class="def-code-arguments">(<var class="var">url</var>)</code><a class="copiable-link" href="#index-imread-1"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-imread-2"><span><code class="def-type">[…] =</code> <strong class="def-name">imread</strong> <code class="def-code-arguments">(…, <var class="var">ext</var>)</code><a class="copiable-link" href="#index-imread-2"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-imread-3"><span><code class="def-type">[…] =</code> <strong class="def-name">imread</strong> <code class="def-code-arguments">(…, <var class="var">idx</var>)</code><a class="copiable-link" href="#index-imread-3"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-imread-4"><span><code class="def-type">[…] =</code> <strong class="def-name">imread</strong> <code class="def-code-arguments">(…, <var class="var">param1</var>, <var class="var">value1</var>, …)</code><a class="copiable-link" href="#index-imread-4"> ¶</a></span></dt>
<dd><p>Read images from various file formats.
</p>
<p>Read an image as a matrix from the file <var class="var">filename</var> or from the online
resource <var class="var">url</var>. If neither is given, but <var class="var">ext</var> was specified, look
for a file with the extension <var class="var">ext</var>.
</p>
<p>The size and class of the output depends on the format of the image. A
color image is returned as an MxNx3 matrix. Grayscale and
black-and-white images are of size MxN. Multipage images will
have an additional 4th dimension.
</p>
<p>The bit depth of the image determines the class of the output:
<code class="code">"uint8"</code>, <code class="code">"uint16"</code>, or <code class="code">"single"</code> for grayscale and
color, and <code class="code">"logical"</code> for black-and-white. Note that indexed images
always return the indexes for a colormap, independent of whether <var class="var">map</var>
is a requested output. To obtain the actual RGB image, use <code class="code">ind2rgb</code>.
When more than one indexed image is being read, <var class="var">map</var> is obtained from
the first. In some rare cases this may be incorrect and <code class="code">imfinfo</code> can
be used to obtain the colormap of each image.
</p>
<p>See the Octave manual for more information in representing images.
(see <a class="pxref" href="Representing-Images.html">Representing Images</a>)
</p>
<p>Some file formats, such as TIFF and GIF, are able to store multiple images
in a single file. <var class="var">idx</var> can be a scalar or vector specifying the
index of the images to read. By default, Octave will read only the first
page.
</p>
<p>Depending on the file format, it is possible to configure the reading of
images with <var class="var">parameter</var>, <var class="var">value</var> pairs. The following options are
supported:
</p>
<dl class="table">
<dt><code class="code">"Frames"</code> or <code class="code">"Index"</code></dt>
<dd><p>This is an alternative method to specify <var class="var">idx</var>. When specifying it
in this way, its value can also be the string <code class="code">"all"</code>.
</p>
</dd>
<dt><code class="code">"Info"</code></dt>
<dd><p>This option exists for <small class="sc">MATLAB</small> compatibility, but has no effect. For
maximum performance when reading multiple images from a single file, use
the <code class="code">"Index"</code> option.
</p>
</dd>
<dt><code class="code">"PixelRegion"</code></dt>
<dd><p>Controls the image region that is read. The value must be a cell array with
two arrays of 3 elements <code class="code">{[<var class="var">rows</var>], [<var class="var">cols</var>]}</code>. The
elements in the array are the start, increment, and end pixel to be read.
If the increment value is omitted it defaults to 1. For example, the
following are all equivalent:
</p>
<div class="format">
<div class="group"><pre class="format-preformatted"><code class="code">imread (filename, "PixelRegion", {[200 600], [300 700]})</code>
<code class="code">imread (filename, "PixelRegion", {[200 1 600], [300 1 700]})</code>
<code class="code">imread (filename)(200:600, 300:700)</code>
</pre></div></div>
</dd>
</dl>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFimwrite">imwrite</a>, <a class="ref" href="#XREFimfinfo">imfinfo</a>, <a class="ref" href="#XREFimformats">imformats</a>.
</p></dd></dl>
<a class="anchor" id="XREFimwrite"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-imwrite"><span><strong class="def-name">imwrite</strong> <code class="def-code-arguments">(<var class="var">img</var>, <var class="var">filename</var>)</code><a class="copiable-link" href="#index-imwrite"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-imwrite-1"><span><strong class="def-name">imwrite</strong> <code class="def-code-arguments">(<var class="var">img</var>, <var class="var">filename</var>, <var class="var">ext</var>)</code><a class="copiable-link" href="#index-imwrite-1"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-imwrite-2"><span><strong class="def-name">imwrite</strong> <code class="def-code-arguments">(<var class="var">img</var>, <var class="var">map</var>, <var class="var">filename</var>)</code><a class="copiable-link" href="#index-imwrite-2"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-imwrite-3"><span><strong class="def-name">imwrite</strong> <code class="def-code-arguments">(…, <var class="var">param1</var>, <var class="var">val1</var>, …)</code><a class="copiable-link" href="#index-imwrite-3"> ¶</a></span></dt>
<dd><p>Write images in various file formats.
</p>
<p>The image <var class="var">img</var> can be a binary, grayscale, RGB, or multi-dimensional
image. The size and class of <var class="var">img</var> should be the same as what should
be expected when reading it with <code class="code">imread</code>: the 3rd and 4th dimensions
reserved for color space, and multiple pages respectively. If it’s an
indexed image, the colormap <var class="var">map</var> must also be specified.
</p>
<p>If <var class="var">ext</var> is not supplied, the file extension of <var class="var">filename</var> is used
to determine the format. The actual supported formats are dependent on
options made during the build of Octave. Use <code class="code">imformats</code> to check
the support of the different image formats.
</p>
<p>Depending on the file format, it is possible to configure the writing of
images with <var class="var">param</var>, <var class="var">val</var> pairs. The following options are
supported:
</p>
<dl class="table">
<dt>‘<samp class="samp">Alpha</samp>’</dt>
<dd><p>Alpha (transparency) channel for the image. This must be a matrix with
same class, and number of rows and columns of <var class="var">img</var>. In case of a
multipage image, the size of the 4th dimension must also match and the third
dimension must be a singleton. By default, image will be completely opaque.
</p>
</dd>
<dt>‘<samp class="samp">Compression</samp>’</dt>
<dd><p>Compression to use one the image. Can be one of the following: "none"
(default), "bzip", "fax3", "fax4", "jpeg", "lzw", "rle", or "deflate".
Note that not all compression types are available for all image formats
in which it defaults to your Magick library.
</p>
</dd>
<dt>‘<samp class="samp">DelayTime</samp>’</dt>
<dd><p>For formats that accept animations (such as GIF), controls for how long a
frame is displayed until it moves to the next one. The value must be scalar
(which will applied to all frames in <var class="var">img</var>), or a vector of length
equal to the number of frames in <var class="var">im</var>. The value is in seconds, must
be between 0 and 655.35, and defaults to 0.5.
</p>
</dd>
<dt>‘<samp class="samp">DisposalMethod</samp>’</dt>
<dd><p>For formats that accept animations (such as GIF), controls what happens to
a frame before drawing the next one. Its value can be one of the
following strings: "doNotSpecify" (default); "leaveInPlace"; "restoreBG";
and "restorePrevious", or a cell array of those string with length equal
to the number of frames in <var class="var">img</var>.
</p>
</dd>
<dt>‘<samp class="samp">LoopCount</samp>’</dt>
<dd><p>For formats that accept animations (such as GIF), controls how many times
the sequence is repeated. A value of Inf means an infinite loop (default),
a value of 0 or 1 that the sequence is played only once (loops zero times),
while a value of 2 or above loops that number of times (looping twice means
it plays the complete sequence 3 times). This option is ignored when there
is only a single image at the end of writing the file.
</p>
</dd>
<dt>‘<samp class="samp">Quality</samp>’</dt>
<dd><p>Set the quality of the compression. The value should be an integer
between 0 and 100, with larger values indicating higher visual quality and
lower compression. Defaults to 75.
</p>
</dd>
<dt>‘<samp class="samp">WriteMode</samp>’</dt>
<dd><p>Some file formats, such as TIFF and GIF, are able to store multiple images
in a single file. This option specifies if <var class="var">img</var> should be appended
to the file (if it exists) or if a new file should be created for it
(possibly overwriting an existing file). The value should be the string
<code class="code">"Overwrite"</code> (default), or <code class="code">"Append"</code>.
</p>
<p>Despite this option, the most efficient method of writing a multipage
image is to pass a 4 dimensional <var class="var">img</var> to <code class="code">imwrite</code>, the same
matrix that could be expected when using <code class="code">imread</code> with the option
<code class="code">"Index"</code> set to <code class="code">"all"</code>.
</p>
</dd>
</dl>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFimread">imread</a>, <a class="ref" href="#XREFimfinfo">imfinfo</a>, <a class="ref" href="#XREFimformats">imformats</a>.
</p></dd></dl>
<a class="anchor" id="XREFIMAGE_005fPATH"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-IMAGE_005fPATH"><span><code class="def-type"><var class="var">val</var> =</code> <strong class="def-name">IMAGE_PATH</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-IMAGE_005fPATH"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-IMAGE_005fPATH-1"><span><code class="def-type"><var class="var">old_val</var> =</code> <strong class="def-name">IMAGE_PATH</strong> <code class="def-code-arguments">(<var class="var">new_val</var>)</code><a class="copiable-link" href="#index-IMAGE_005fPATH-1"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-IMAGE_005fPATH-2"><span><code class="def-type"><var class="var">old_val</var> =</code> <strong class="def-name">IMAGE_PATH</strong> <code class="def-code-arguments">(<var class="var">new_val</var>, "local")</code><a class="copiable-link" href="#index-IMAGE_005fPATH-2"> ¶</a></span></dt>
<dd><p>Query or set the internal variable that specifies a colon separated
list of directories in which to search for image files.
</p>
<p>When called from inside a function with the <code class="code">"local"</code> option, the
variable is changed locally for the function and any subroutines it calls.
The original variable value is restored when exiting the function.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="Controlling-Subprocesses.html#XREFEXEC_005fPATH">EXEC_PATH</a>, <a class="ref" href="System-Information.html#XREFOCTAVE_005fHOME">OCTAVE_HOME</a>, <a class="ref" href="System-Information.html#XREFOCTAVE_005fEXEC_005fHOME">OCTAVE_EXEC_HOME</a>.
</p></dd></dl>
<p>It is possible to get information about an image file on disk, without actually
reading it into Octave. This is done using the <code class="code">imfinfo</code> function which
provides read access to many of the parameters stored in the header of the
image file.
</p>
<a class="anchor" id="XREFimfinfo"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-imfinfo"><span><code class="def-type"><var class="var">info</var> =</code> <strong class="def-name">imfinfo</strong> <code class="def-code-arguments">(<var class="var">filename</var>)</code><a class="copiable-link" href="#index-imfinfo"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-imfinfo-1"><span><code class="def-type"><var class="var">info</var> =</code> <strong class="def-name">imfinfo</strong> <code class="def-code-arguments">(<var class="var">url</var>)</code><a class="copiable-link" href="#index-imfinfo-1"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-imfinfo-2"><span><code class="def-type"><var class="var">info</var> =</code> <strong class="def-name">imfinfo</strong> <code class="def-code-arguments">(…, <var class="var">ext</var>)</code><a class="copiable-link" href="#index-imfinfo-2"> ¶</a></span></dt>
<dd><p>Read image information from a file.
</p>
<p><code class="code">imfinfo</code> returns a structure containing information about the image
stored in the file <var class="var">filename</var>. If there is no file <var class="var">filename</var>,
and <var class="var">ext</var> was specified, it will look for a file named <var class="var">filename</var>
and extension <var class="var">ext</var>, i.e., a file named <var class="var">filename</var>.<var class="var">ext</var>.
</p>
<p>The output structure <var class="var">info</var> contains the following fields:
</p>
<dl class="table">
<dt>‘<samp class="samp">Filename</samp>’</dt>
<dd><p>The full name of the image file.
</p>
</dd>
<dt>‘<samp class="samp">FileModDate</samp>’</dt>
<dd><p>Date of last modification to the file.
</p>
</dd>
<dt>‘<samp class="samp">FileSize</samp>’</dt>
<dd><p>Number of bytes of the image on disk
</p>
</dd>
<dt>‘<samp class="samp">Format</samp>’</dt>
<dd><p>Image format (e.g., <code class="code">"jpeg"</code>).
</p>
</dd>
<dt>‘<samp class="samp">Height</samp>’</dt>
<dd><p>Image height in pixels.
</p>
</dd>
<dt>‘<samp class="samp">Width</samp>’</dt>
<dd><p>Image Width in pixels.
</p>
</dd>
<dt>‘<samp class="samp">BitDepth</samp>’</dt>
<dd><p>Number of bits per channel per pixel.
</p>
</dd>
<dt>‘<samp class="samp">ColorType</samp>’</dt>
<dd><p>Image type. Value is <code class="code">"grayscale"</code>, <code class="code">"indexed"</code>,
<code class="code">"truecolor"</code>, <code class="code">"CMYK"</code>, or <code class="code">"undefined"</code>.
</p>
</dd>
<dt>‘<samp class="samp">XResolution</samp>’</dt>
<dd><p>X resolution of the image.
</p>
</dd>
<dt>‘<samp class="samp">YResolution</samp>’</dt>
<dd><p>Y resolution of the image.
</p>
</dd>
<dt>‘<samp class="samp">ResolutionUnit</samp>’</dt>
<dd><p>Units of image resolution. Value is <code class="code">"Inch"</code>,
<code class="code">"Centimeter"</code>, or <code class="code">"undefined"</code>.
</p>
</dd>
<dt>‘<samp class="samp">DelayTime</samp>’</dt>
<dd><p>Time in 1/100ths of a second (0 to 65535) which must expire before
displaying the next image in an animated sequence.
</p>
</dd>
<dt>‘<samp class="samp">LoopCount</samp>’</dt>
<dd><p>Number of iterations to loop an animation.
</p>
</dd>
<dt>‘<samp class="samp">ByteOrder</samp>’</dt>
<dd><p>Endian option for formats that support it. Value is
<code class="code">"little-endian"</code>, <code class="code">"big-endian"</code>, or <code class="code">"undefined"</code>.
</p>
</dd>
<dt>‘<samp class="samp">Gamma</samp>’</dt>
<dd><p>Gamma level of the image. The same color image displayed on two different
workstations may look different due to differences in the display monitor.
</p>
</dd>
<dt>‘<samp class="samp">Quality</samp>’</dt>
<dd><p>JPEG/MIFF/PNG compression level. Value is an integer in the range [0 100].
</p>
</dd>
<dt>‘<samp class="samp">DisposalMethod</samp>’</dt>
<dd><p>Only valid for GIF images, control how successive frames are rendered (how
the preceding frame is disposed of) when creating a GIF animation. Values
can be <code class="code">"doNotSpecify"</code>, <code class="code">"leaveInPlace"</code>, <code class="code">"restoreBG"</code>,
or <code class="code">"restorePrevious"</code>. For non-GIF files, value is an empty string.
</p>
</dd>
<dt>‘<samp class="samp">Chromaticities</samp>’</dt>
<dd><p>Value is a 1x8 Matrix with the x,y chromaticity values for white, red,
green, and blue points, in that order.
</p>
</dd>
<dt>‘<samp class="samp">Comment</samp>’</dt>
<dd><p>Image comment.
</p>
</dd>
<dt>‘<samp class="samp">Compression</samp>’</dt>
<dd><p>Compression type. Value can be <code class="code">"none"</code>, <code class="code">"bzip"</code>,
<code class="code">"fax3"</code>, <code class="code">"fax4"</code>, <code class="code">"jpeg"</code>, <code class="code">"lzw"</code>,
<code class="code">"rle"</code>, <code class="code">"deflate"</code>, <code class="code">"lzma"</code>, <code class="code">"jpeg2000"</code>,
<code class="code">"jbig2"</code>, <code class="code">"jbig2"</code>, or <code class="code">"undefined"</code>.
</p>
</dd>
<dt>‘<samp class="samp">Colormap</samp>’</dt>
<dd><p>Colormap for each image.
</p>
</dd>
<dt>‘<samp class="samp">Orientation</samp>’</dt>
<dd><p>The orientation of the image with respect to the rows and columns. Value
is an integer between 1 and 8 as defined in the TIFF 6 specifications, and
for <small class="sc">MATLAB</small> compatibility.
</p>
</dd>
<dt>‘<samp class="samp">Software</samp>’</dt>
<dd><p>Name and version of the software or firmware of the camera or image input
device used to generate the image.
</p>
</dd>
<dt>‘<samp class="samp">Make</samp>’</dt>
<dd><p>The manufacturer of the recording equipment. This is the manufacture of the
DSC, scanner, video digitizer or other equipment that generated
the image.
</p>
</dd>
<dt>‘<samp class="samp">Model</samp>’</dt>
<dd><p>The model name or model number of the recording equipment as mentioned on
the field <code class="code">"Make"</code>.
</p>
</dd>
<dt>‘<samp class="samp">DateTime</samp>’</dt>
<dd><p>The date and time of image creation as defined by the Exif standard, i.e.,
it is the date and time the file was changed.
</p>
</dd>
<dt>‘<samp class="samp">ImageDescription</samp>’</dt>
<dd><p>The title of the image as defined by the Exif standard.
</p>
</dd>
<dt>‘<samp class="samp">Artist</samp>’</dt>
<dd><p>Name of the camera owner, photographer or image creator.
</p>
</dd>
<dt>‘<samp class="samp">Copyright</samp>’</dt>
<dd><p>Copyright notice of the person or organization claiming rights to the image.
</p>
</dd>
<dt>‘<samp class="samp">DigitalCamera</samp>’</dt>
<dd><p>A struct with information retrieved from the Exif tag.
</p>
</dd>
<dt>‘<samp class="samp">GPSInfo</samp>’</dt>
<dd><p>A struct with geotagging information retrieved from the Exif tag.
</p></dd>
</dl>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFimread">imread</a>, <a class="ref" href="#XREFimwrite">imwrite</a>, <a class="ref" href="Displaying-Images.html#XREFimshow">imshow</a>, <a class="ref" href="#XREFimformats">imformats</a>.
</p></dd></dl>
<p>By default, Octave’s image IO functions (<code class="code">imread</code>, <code class="code">imwrite</code>,
and <code class="code">imfinfo</code>) use the <code class="code">GraphicsMagick</code> library for their
operations. This means a vast number of image formats is supported
but considering the large amount of image formats in science and
its commonly closed nature, it is impossible to have a library
capable of reading them all. Because of this, the function
<code class="code">imformats</code> keeps a configurable list of available formats,
their extensions, and what functions should the image IO functions
use. This allows one to expand Octave’s image IO capabilities by
creating functions aimed at acting on specific file formats.
</p>
<p>While it would be possible to call the extra functions directly,
properly configuring Octave with <code class="code">imformats</code> allows one to keep a
consistent code that is abstracted from file formats.
</p>
<p>It is important to note that a file format is not actually defined by its
file extension and that <code class="code">GraphicsMagick</code> is capable to read and write
more file formats than the ones listed by <code class="code">imformats</code>. What this
means is that even with an incorrect or missing extension the image may
still be read correctly, and that even unlisted formats are not necessarily
unsupported.
</p>
<a class="anchor" id="XREFimformats"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-imformats"><span><strong class="def-name">imformats</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-imformats"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-imformats-1"><span><code class="def-type"><var class="var">formats</var> =</code> <strong class="def-name">imformats</strong> <code class="def-code-arguments">(<var class="var">ext</var>)</code><a class="copiable-link" href="#index-imformats-1"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-imformats-2"><span><code class="def-type"><var class="var">formats</var> =</code> <strong class="def-name">imformats</strong> <code class="def-code-arguments">(<var class="var">format</var>)</code><a class="copiable-link" href="#index-imformats-2"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-imformats-3"><span><code class="def-type"><var class="var">formats</var> =</code> <strong class="def-name">imformats</strong> <code class="def-code-arguments">("add", <var class="var">format</var>)</code><a class="copiable-link" href="#index-imformats-3"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-imformats-4"><span><code class="def-type"><var class="var">formats</var> =</code> <strong class="def-name">imformats</strong> <code class="def-code-arguments">("remove", <var class="var">ext</var>)</code><a class="copiable-link" href="#index-imformats-4"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-imformats-5"><span><code class="def-type"><var class="var">formats</var> =</code> <strong class="def-name">imformats</strong> <code class="def-code-arguments">("update", <var class="var">ext</var>, <var class="var">format</var>)</code><a class="copiable-link" href="#index-imformats-5"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-imformats-6"><span><code class="def-type"><var class="var">formats</var> =</code> <strong class="def-name">imformats</strong> <code class="def-code-arguments">("factory")</code><a class="copiable-link" href="#index-imformats-6"> ¶</a></span></dt>
<dd><p>Manage supported image formats.
</p>
<p><var class="var">formats</var> is a structure with information about each supported file
format, or from a specific format <var class="var">ext</var>, the value displayed on the
field <var class="var">ext</var>. It contains the following fields:
</p>
<dl class="table">
<dt>ext</dt>
<dd><p>The name of the file format. This may match the file extension but Octave
will automatically detect the file format.
</p>
</dd>
<dt>description</dt>
<dd><p>A long description of the file format.
</p>
</dd>
<dt>isa</dt>
<dd><p>A function handle to confirm if a file is of the specified format.
</p>
</dd>
<dt>write</dt>
<dd><p>A function handle to write if a file is of the specified format.
</p>
</dd>
<dt>read</dt>
<dd><p>A function handle to open files the specified format.
</p>
</dd>
<dt>info</dt>
<dd><p>A function handle to obtain image information of the specified format.
</p>
</dd>
<dt>alpha</dt>
<dd><p>Logical value if format supports alpha channel (transparency or matte).
</p>
</dd>
<dt>multipage</dt>
<dd><p>Logical value if format supports multipage (multiple images per file).
</p></dd>
</dl>
<p>It is possible to change the way Octave manages file formats with the
options <code class="code">"add"</code>, <code class="code">"remove"</code>, and <code class="code">"update"</code>, and supplying
a structure <var class="var">format</var> with the required fields. The option
<code class="code">"factory"</code> resets the configuration to the default.
</p>
<p>This can be used by Octave packages to extend the image reading capabilities
Octave, through use of the PKG_ADD and PKG_DEL commands.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFimfinfo">imfinfo</a>, <a class="ref" href="#XREFimread">imread</a>, <a class="ref" href="#XREFimwrite">imwrite</a>.
</p></dd></dl>
</div>
<hr>
<div class="nav-panel">
<p>
Next: <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>
|