<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>CCfits: Reading an Image</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.1 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li class="current"><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li><a href="files.html"><span>Files</span></a></li> </ul> </div> </div> <div class="contents"> <h1><a class="anchor" id="readimage">Reading an Image </a></h1><p>Image reading calls are made very simple: the FITS object is created with the readDataFlag set to true, and reading is done on construction. The following call</p> <p>image.read(contents)</p> <p>calls</p> <p>PHDU::read(std::valarray<S>& image).</p> <p>This copies the entire image from the FITS object into the std::valarray object contents, sizing it as necessary. PHDU::read() and ExtHDU::read() [for image extensions] take a range of arguments that support (a) reading the entire image - as in this example; (b) sections of an image starting from a given pixel; (c) rectangular subsets. See the class references for PHDU and ExtHDU for details.</p> <div class="fragment"><pre class="fragment"> <span class="keywordtype">int</span> readImage() { std::auto_ptr<FITS> pInfile(<span class="keyword">new</span> FITS(<span class="stringliteral">"atestfil.fit"</span>,Read,<span class="keyword">true</span>)); PHDU& image = pInfile->pHDU(); std::valarray<unsigned long> contents; <span class="comment">// read all user-specifed, coordinate, and checksum keys in the image</span> image.readAllKeys(); image.read(contents); <span class="comment">// this doesn't print the data, just header info.</span> std::cout << image << std::endl; <span class="keywordtype">long</span> ax1(image.axis(0)); <span class="keywordtype">long</span> ax2(image.axis(1)); <span class="keywordflow">for</span> (<span class="keywordtype">long</span> j = 0; j < ax2; j+=10) { std::ostream_iterator<short> c(std::cout,<span class="stringliteral">"\t"</span>); std::copy(&contents[j*ax1],&contents[(j+1)*ax1-1],c); std::cout << <span class="charliteral">'\n'</span>; } std::cout << std::endl; <span class="keywordflow">return</span> 0; } </pre></div> </div> <hr size="1"/><address style="text-align: right;"><small>Generated on Wed Sep 9 11:59:41 2009 for CCfits by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> </body> </html>