cacao  Release 0.1.03-dev
Compute And Control For Adaptive Optics
image_format.c File Reference

Convert between image formats. More...

#include <stdint.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <sys/file.h>
#include "CommandLineInterface/CLIcore.h"
#include "00CORE/00CORE.h"
#include "COREMOD_memory/COREMOD_memory.h"
#include "COREMOD_arith/COREMOD_arith.h"
#include "COREMOD_tools/COREMOD_tools.h"
#include "COREMOD_iofits/COREMOD_iofits.h"
#include "statistic/statistic.h"
#include "image_format/image_format.h"
#include "info/info.h"
#include "fft/fft.h"
#include "image_gen/image_gen.h"
Include dependency graph for image_format.c:

Data Structures

struct  BITMAPFILEHEADER
 
struct  BITMAPINFOHEADER
 
struct  sImage
 

Macros

#define MODULE_SHORTNAME_DEFAULT   ""
 
#define MODULE_DESCRIPTION   "Conversion between image format, I/O"
 
#define MODULE_APPLICATION   "milk"
 
#define SWAP(x, y)   tmp=(x);x=(y);y=tmp;
 
#define PI   3.14159265358979323846264338328
 
#define BMP_BIG_ENDIAN   0
 
#define uint16   unsigned short
 
#define uint32   unsigned int
 
#define BI_RGB   0
 
#define BM   19778
 
#define BMP_FALSE   0
 
#define BMP_TRUE   1
 

Functions

CLI bindings
errno_t image_writeBMP_auto_cli ()
 
errno_t IMAGE_FORMAT_im_to_ASCII_cli ()
 
errno_t CR2toFITS_cli ()
 
errno_t IMAGE_FORMAT_FITS_to_ushortintbin_lock_cli ()
 
errno_t IMAGE_FORMAT_FITS_to_floatbin_lock_cli ()
 
errno_t IMAGE_FORMAT_read_binary32f_cli ()
 
errno_t IMAGE_FORMAT_extract_RGGBchan_cli ()
 
errno_t IMAGE_FORMAT_loadCR2toFITSRGB_cli ()
 
Module initialization
static errno_t init_module_CLI ()
 
image_format functions
errno_t IMAGE_FORMAT_im_to_ASCII (const char *IDname, const char *foutname)
 
uint16 setUint16 (uint16 x)
 
uint32 setUint32 (uint32 x)
 
static uint32 write24BitBmpFile (const char *filename, uint32 width, uint32 height, unsigned char *image)
 
errno_t image_writeBMP_auto (const char *IDnameR, const char *IDnameG, const char *IDnameB, const char *outname)
 
static errno_t image_writeBMP (const char *IDnameR, const char *IDnameG, const char *IDnameB, const char *outname)
 
long getImageInfo (FILE *inputFile, long offset, int numberOfChars)
 
imageID read_ASCIIimage (const char *filename, const char *ID_name, long xsize, long ysize)
 
imageID read_ASCIIimage1 (const char *filename, const char *ID_name, long xsize, long ysize)
 
errno_t read_BMPimage (char *filename, const char *IDname_R, const char *IDname_G, const char *IDname_B)
 
imageID read_PGMimage (const char *fname, const char *ID_name)
 
imageID CR2toFITS (const char *fnameCR2, const char *fnameFITS)
 
imageID loadCR2 (const char *fnameCR2, const char *IDname)
 
long CR2toFITS_strfilter (const char *strfilter)
 
errno_t image_format_extract_RGGBchan (const char *ID_name, const char *IDoutR_name, const char *IDoutG1_name, const char *IDoutG2_name, const char *IDoutB_name)
 
imageID image_format_reconstruct_from_RGGBchan (const char *IDr_name, const char *IDg1_name, const char *IDg2_name, const char *IDb_name, const char *IDout_name)
 
errno_t convert_rawbayerFITStorgbFITS_simple (const char *ID_name, const char *ID_name_r, const char *ID_name_g, const char *ID_name_b, int SamplFactor)
 
errno_t loadCR2toFITSRGB (const char *fnameCR2, const char *fnameFITSr, const char *fnameFITSg, const char *fnameFITSb)
 
errno_t CR2tomov ()
 
imageID IMAGE_FORMAT_requantize (const char *IDin_name, const char *IDout_name, double alpha, double RON, double gain, double bias)
 
imageID IMAGE_FORMAT_dequantize (const char *IDin_name, const char *IDout_name, double alpha, double RON, double gain, double bias)
 
imageID IMAGE_FORMAT_read_binary16 (const char *fname, long xsize, long ysize, const char *IDname)
 
imageID IMAGE_FORMAT_read_binary32f (const char *fname, long xsize, long ysize, const char *IDname)
 
imageID IMAGE_FORMAT_FITS_to_ushortintbin_lock (const char *IDname, const char *fname)
 
imageID IMAGE_FORMAT_FITS_to_floatbin_lock (const char *IDname, const char *fname)
 

Variables

static int CR2toFITS_NORM
 
static float FLUXFACTOR = 1.0
 

Detailed Description

Convert between image formats.

read and write images other than FITS

Macro Definition Documentation

◆ BI_RGB

#define BI_RGB   0

◆ BM

#define BM   19778

◆ BMP_BIG_ENDIAN

#define BMP_BIG_ENDIAN   0

◆ BMP_FALSE

#define BMP_FALSE   0

◆ BMP_TRUE

#define BMP_TRUE   1

◆ MODULE_APPLICATION

#define MODULE_APPLICATION   "milk"

◆ MODULE_DESCRIPTION

#define MODULE_DESCRIPTION   "Conversion between image format, I/O"

◆ MODULE_SHORTNAME_DEFAULT

#define MODULE_SHORTNAME_DEFAULT   ""

◆ PI

#define PI   3.14159265358979323846264338328

◆ SWAP

#define SWAP (   x,
 
)    tmp=(x);x=(y);y=tmp;

◆ uint16

#define uint16   unsigned short

◆ uint32

#define uint32   unsigned int

Function Documentation

◆ convert_rawbayerFITStorgbFITS_simple()

errno_t convert_rawbayerFITStorgbFITS_simple ( const char *  ID_name,
const char *  ID_name_r,
const char *  ID_name_g,
const char *  ID_name_b,
int  SamplFactor 
)

◆ CR2toFITS()

imageID CR2toFITS ( const char *  fnameCR2,
const char *  fnameFITS 
)

Purpose

Convert CR2 to FITS

Note
assumes dcraw is installed

◆ CR2toFITS_cli()

errno_t CR2toFITS_cli ( )

◆ CR2toFITS_strfilter()

long CR2toFITS_strfilter ( const char *  strfilter)

◆ CR2tomov()

errno_t CR2tomov ( )

◆ getImageInfo()

long getImageInfo ( FILE *  inputFile,
long  offset,
int  numberOfChars 
)

◆ IMAGE_FORMAT_dequantize()

imageID IMAGE_FORMAT_dequantize ( const char *  IDin_name,
const char *  IDout_name,
double  alpha,
double  RON,
double  gain,
double  bias 
)

◆ image_format_extract_RGGBchan()

errno_t image_format_extract_RGGBchan ( const char *  ID_name,
const char *  IDoutR_name,
const char *  IDoutG1_name,
const char *  IDoutG2_name,
const char *  IDoutB_name 
)

◆ IMAGE_FORMAT_extract_RGGBchan_cli()

errno_t IMAGE_FORMAT_extract_RGGBchan_cli ( )

◆ IMAGE_FORMAT_FITS_to_floatbin_lock()

imageID IMAGE_FORMAT_FITS_to_floatbin_lock ( const char *  IDname,
const char *  fname 
)

◆ IMAGE_FORMAT_FITS_to_floatbin_lock_cli()

errno_t IMAGE_FORMAT_FITS_to_floatbin_lock_cli ( )

◆ IMAGE_FORMAT_FITS_to_ushortintbin_lock()

imageID IMAGE_FORMAT_FITS_to_ushortintbin_lock ( const char *  IDname,
const char *  fname 
)

◆ IMAGE_FORMAT_FITS_to_ushortintbin_lock_cli()

errno_t IMAGE_FORMAT_FITS_to_ushortintbin_lock_cli ( )

◆ IMAGE_FORMAT_im_to_ASCII()

errno_t IMAGE_FORMAT_im_to_ASCII ( const char *  IDname,
const char *  foutname 
)

◆ IMAGE_FORMAT_im_to_ASCII_cli()

errno_t IMAGE_FORMAT_im_to_ASCII_cli ( )

◆ IMAGE_FORMAT_loadCR2toFITSRGB_cli()

errno_t IMAGE_FORMAT_loadCR2toFITSRGB_cli ( )

◆ IMAGE_FORMAT_read_binary16()

imageID IMAGE_FORMAT_read_binary16 ( const char *  fname,
long  xsize,
long  ysize,
const char *  IDname 
)

◆ IMAGE_FORMAT_read_binary32f()

imageID IMAGE_FORMAT_read_binary32f ( const char *  fname,
long  xsize,
long  ysize,
const char *  IDname 
)

◆ IMAGE_FORMAT_read_binary32f_cli()

errno_t IMAGE_FORMAT_read_binary32f_cli ( )

◆ image_format_reconstruct_from_RGGBchan()

imageID image_format_reconstruct_from_RGGBchan ( const char *  IDr_name,
const char *  IDg1_name,
const char *  IDg2_name,
const char *  IDb_name,
const char *  IDout_name 
)

◆ IMAGE_FORMAT_requantize()

imageID IMAGE_FORMAT_requantize ( const char *  IDin_name,
const char *  IDout_name,
double  alpha,
double  RON,
double  gain,
double  bias 
)

◆ image_writeBMP()

static errno_t image_writeBMP ( const char *  IDnameR,
const char *  IDnameG,
const char *  IDnameB,
const char *  outname 
)
static

◆ image_writeBMP_auto()

errno_t image_writeBMP_auto ( const char *  IDnameR,
const char *  IDnameG,
const char *  IDnameB,
const char *  outname 
)

◆ image_writeBMP_auto_cli()

errno_t image_writeBMP_auto_cli ( )

◆ init_module_CLI()

static errno_t init_module_CLI ( )
static

◆ loadCR2()

imageID loadCR2 ( const char *  fnameCR2,
const char *  IDname 
)

Purpose

load CR2 file

Note
assumes dcraw is installed

◆ loadCR2toFITSRGB()

errno_t loadCR2toFITSRGB ( const char *  fnameCR2,
const char *  fnameFITSr,
const char *  fnameFITSg,
const char *  fnameFITSb 
)

◆ read_ASCIIimage()

imageID read_ASCIIimage ( const char *  filename,
const char *  ID_name,
long  xsize,
long  ysize 
)

◆ read_ASCIIimage1()

imageID read_ASCIIimage1 ( const char *  filename,
const char *  ID_name,
long  xsize,
long  ysize 
)

◆ read_BMPimage()

errno_t read_BMPimage ( char *  filename,
const char *  IDname_R,
const char *  IDname_G,
const char *  IDname_B 
)

◆ read_PGMimage()

imageID read_PGMimage ( const char *  fname,
const char *  ID_name 
)

Purpose

reads PGM images (16 bit only)

Note
written to read output of "dcraw -t 0 -D -4 xxx.CR2" into FITS

◆ setUint16()

uint16 setUint16 ( uint16  x)

◆ setUint32()

uint32 setUint32 ( uint32  x)

◆ write24BitBmpFile()

static uint32 write24BitBmpFile ( const char *  filename,
uint32  width,
uint32  height,
unsigned char *  image 
)
static

Purpose

This function writes out a 24-bit Windows bitmap file that is readable by Microsoft Paint.
The image data is a 1D array of (r, g, b) triples, where individual (r, g, b) values can
each take on values between 0 and 255, inclusive.

Arguments

Parameters
[in]filenamechar* A string representing the filename that will be written
[in]widthuint32 The width, in pixels, of the bitmap

Variable Documentation

◆ CR2toFITS_NORM

int CR2toFITS_NORM
static
Initial value:
=
0

◆ FLUXFACTOR

float FLUXFACTOR = 1.0
static