Main Page   Compound List   File List   Compound Members   File Members  

fits_read_image.c

Go to the documentation of this file.
00001 
00028 #include <string.h>
00029 #include <stdio.h>
00030 #include <fitsio.h>
00031 #include <malloc.h>
00032 
00033 #include "mex.h"
00034 #include "matrix.h"
00035 #include "mfitsio.h"
00036 
00047 void
00048 mexFunction (int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[])
00049 {
00050   int buflen, status;
00051   char *filename;
00052   mfitsio_header *header;
00053   mfitsio_info *info;
00056   /* Check proper input and output */
00057   if (nrhs != 1)
00058     mexErrMsgTxt ("One input required.");
00059   else if (nlhs > 1)
00060     mexErrMsgTxt ("Too many output arguments.");
00061   else if (!mxIsChar (prhs[0]))
00062     mexErrMsgTxt ("Input must be a string (filename).");
00063 
00064   if (mxGetM (prhs[0]) != 1)
00065     mexErrMsgTxt ("Input must be a row vector string (filename).");
00066 
00067   buflen = (mxGetM (prhs[0]) * mxGetN (prhs[0])) + 1;
00068 
00069   filename = mxCalloc (buflen, sizeof (char));
00070   status = mxGetString (prhs[0], filename, buflen);
00071 
00072   header = mfitsio_read_header (filename);
00073   if (header != 0)
00074   {
00076     info = mfitsio_read_info (filename);
00077     plhs[0] = mfitsio_read_image (filename, info);
00078     mfitsio_free_header (header);
00079     mfitsio_free_info (info);
00080   }
00081   else
00082   {
00083     mexErrMsgTxt ("Unable to open FITS file.");
00084   }
00085 
00086   return;
00087 }


Operated by University of California for the National Nuclear Security Administration of the US Department of Energy. Copyright © 2002-2003 UC | Disclaimer/Privacy
This website has been approved for unlimited release with associated LA-UR number LA-UR-03-0949.