Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Static Public Member Functions | Static Protected Member Functions | Static Protected Attributes | List of all members
BIAS::ImageIO Class Reference

Routines for loading and writing all kinds of image formats. More...

#include <Base/Image/ImageIO.hh>

Public Types

enum  TFileFormat {
  FF_auto =4242, FF_unknown =9999, FF_mip =0, FF_ppm =1,
  FF_pgm =2, FF_jpg =3, FF_tif =4, FF_png =5,
  FF_viff =6, FF_exr =7, FF_dds =8, FF_raw4096 =9,
  FF_bmp =10, FF_pbm =12, FF_Real32 =13, FF_matrix =14
}
 format specifier when writing an image to a file Do NOT change order or associated enum value because it may confuse IO rotines for loading old images. More...
 

Static Public Member Functions

static int ExportDevIL (const std::string &FileName, const ImageBase &img, const bool &fileOverwrite=true, const bool &allowPadding=true)
 Save to disk using the DevIL/OpenIL library. More...
 
static int ExportLibJPEG (const std::string &filename, const BIAS::ImageBase &image, const int quality=100)
 Writes an image to disk using the LibJPEG library encapsulated in ExportImage. More...
 
static int ExportMagickPP (const std::string &FileName, const ImageBase img, const int &quality=BIAS_DEFAULT_IMAGE_QUALITY, const bool &writeMetaData=false, const bool &forceBinaryPNMformat=true, const bool &losslesJpgMode=false, const bool &writeGZipped=false, const std::string &comment=std::string(""))
 Reads an image from disk using the ImageMagick++ library. More...
 
static int ExportMatrix (const std::string &FileName, const ImageBase &img, const bool verbose)
 Export BIAS images to text images. More...
 
static int ExportOpenCV (const std::string &filename, const ImageBase &image)
 Write an image to disk using the OpenCV library. More...
 
static int ExportOpenEXR (const std::string &FileName, const ImageBase &input)
 save an .exr OpenEXR image to disk. More...
 
static int ExportTIFFLIB (const std::string &FileName, const BIAS::ImageBase &img, const unsigned int rowsPerStripArg=0, const unsigned int compressionAlgo=BIAS_COMPRESSION_NONE, const std::string &comment=std::string("BIAS::ImageIO Jan Woetzel"))
 Write image to disk using TiffLib directly. More...
 
static std::string ExtensionName (const std::string &oldName, const std::string &newExtension)
 appends extension to name if extension is not already extension, avoids double extension like ".pgm.pgm" More...
 
static std::string GetExtension (const BIAS::ImageIO::TFileFormat &fmt)
 return the default extension for a given FileFormat enum More...
 
static BIAS::ImageIO::TFileFormat GetFileFormat (const std::string &str)
 determines the BIAS::ImageIO::TFileFormat for a given filename/ extension Decision based on extension comparison More...
 
static int ImportDevIL (const std::string &FileName, ImageBase &result, const unsigned int &tex3DplaneZ=1)
 Reads an image from disk using the DevIL/OpenIL library. More...
 
static int ImportImage (const std::string &filename, ImageBase &result)
 Try to load/import an image from a file using external libs. More...
 
static int ImportLibJPEG (const std::string &filename, BIAS::ImageBase &result, bool readComment=true)
 Reads an image from disk using the LibJPEG library encapsulated in ImportImage. More...
 
static int ImportMagickPP (const std::string &FileName, ImageBase &result, const bool &dummy=false, const bool &readMetaData=true)
 Reads an image from disk using the ImageMagick++ library. More...
 
static int ImportMagickPPAutoconvert (const std::string &FileName, ImageBase &result, const bool &assumeGrey=false, const bool &readMetaData=false)
 Reads an image from disk using the ImageMagick++ library. More...
 
static int ImportMatrix (const std::string &FileName, ImageBase &img, const bool verbose)
 Import text images to BIAS. More...
 
static int ImportOpenCV (const std::string &filename, ImageBase &image)
 Reads an image from disk using the OpenCV library. More...
 
static int ImportOpenEXR (const std::string &FileName, ImageBase &result)
 load an .exr OpenEXR image from disk. More...
 
static int ImportRADIANCE (const std::string &FileName, ImageBase &result)
 import Greg Wards Radiance RGBE image format (.hdr, .rad) A high dynamic range RGBE image contains 24 bits RGB Mantissa and 8 common exponent bits that encode the dynamic range. More...
 
static int ImportRAWwithHeader (const std::string &filename, BIAS::ImageBase &img)
 Reads a proprietary .RAW format from disk A typical file consists of these blocks: More...
 
static int ImportReal32 (const std::string &FileName, ImageBase &result)
 Loads proprietary raw floating point 2d image from Mathematica Real32 values Example how to export in Mathematica: More...
 
static int ImportTIFFLIB (const std::string &FileName, ImageBase &img)
 read a tiff image from disk using TiffLib directly More...
 
static void InitDevIL ()
 initialize devIL once globally. More...
 
static int Load (const std::string &FileName, ImageBase &img)
 first tries a call to Read MIP image and if that fails, tries to Import Image with all other available format loaders and third party libraries. More...
 
static int ParseRAWwithHeader (const std::string &buf, const std::string &tag, unsigned int &retVal)
 helper function for ImportRAWwithHeader Parses buf for tag More...
 
static void PrintInfoDevIL (std::ostream &os=std::cout)
 print info in currently bound DevIL image More...
 
static int Save (const std::string &filename, const ImageBase &img, const enum TFileFormat FileFormat=FF_auto, const bool sync=BIAS_DEFAULT_SYNC, const int c_jpeg_quality=BIAS_DEFAULT_IMAGE_QUALITY, const bool forceNewID=BIAS_DEFAULT_FORCENEWID, const bool &writeMetaData=true)
 Export image as file using extrnal libs. More...
 
static int WriteRAW_IMA (const std::string &FileName, const ImageBase &img_const)
 Write image in binary file format needed by RealEyes. More...
 
static int WriteUnbuffered (const std::string &FileName, const ImageBase &img)
 Write a mip binary image to disk circumventing OS caches as good as possible. More...
 

Static Protected Member Functions

static int ExportImagePnm_ (const std::string &FileName, const ImageBase &img, bool sync=false, const bool &writeMetaData=true)
 
static int ImportImagePnm_ (std::ifstream &ifs, ImageBase &result, int depth)
 
static int ImportImageViff_ (std::ifstream &ifs, ImageBase &result)
 import a one channel grey float viff image (Khoros image format) for compatibility to old stereo code More...
 
static int Read_ (const std::string &FileName, ImageBase &img)
 Read a proprietary mip binary Image from disk and allocate memory structure. More...
 
static int Write_ (const std::string &FileName, const ImageBase &img, const bool sync=false, const bool forceNewID=true)
 Write a proprietary mip binary Image to disk. More...
 

Static Protected Attributes

static char * MemAlignedBuffer_ = NULL
 
static unsigned long int MemAlignedBufferSize_ = 0
 

Detailed Description

Routines for loading and writing all kinds of image formats.

Note
Use Load/Save and Import/ExportImage for foreign+internal file formats For proprietary mip format use extension mip and Load/Save. As all functions are static call them like ImageIO::Load().

Definition at line 69 of file ImageIO.hh.

Member Enumeration Documentation

format specifier when writing an image to a file Do NOT change order or associated enum value because it may confuse IO rotines for loading old images.

Enumerator
FF_auto 
FF_unknown 
FF_mip 
FF_ppm 
FF_pgm 
FF_jpg 
FF_tif 
FF_png 
FF_viff 
FF_exr 
FF_dds 
FF_raw4096 
FF_bmp 
FF_pbm 
FF_Real32 
FF_matrix 

Definition at line 76 of file ImageIO.hh.

Member Function Documentation

int ImageIO::ExportDevIL ( const std::string &  FileName,
const ImageBase img,
const bool &  fileOverwrite = true,
const bool &  allowPadding = true 
)
static

Save to disk using the DevIL/OpenIL library.

See http://openil.sourceforge.net for details. Supports writing multiple formats, including

  • .dds
  • .tga, .tif,
  • .bmp, .jpg, .pcx, .png, .pnm
  • .sgi,.tga the fiel format is determined from the Filenames extension.
    Returns
    0 in case of succes, negative value in case of error.
    Parameters
    FileNamethe output filename to read from.
    imgimage to be saved
    fileOverwritetrue to overwrite file if exists
    Author
    Jan Woetzel 12/2005

Definition at line 2288 of file ImageIO.cpp.

References BIAS::ImageBase::CM_BGR, BIAS::ImageBase::CM_BGRA, BIAS::ImageBase::CM_Grey, BIAS::ImageBase::CM_GreyA, BIAS::ImageBase::CM_RGB, BIAS::ImageBase::CM_RGBA, BIAS::ImageBase::GetChannelCount(), BIAS::ImageBase::GetColorModel(), BIAS::ImageBase::GetDepth(), BIAS::ImageBase::GetHeight(), BIAS::ImageBase::GetImageData(), BIAS::ImageBase::GetPixelCount(), BIAS::ImageBase::GetStorageType(), BIAS::ImageBase::GetWidth(), BIAS::ImageBase::PadToPowerOfTwo(), BIAS::ImageBase::ST_char, BIAS::ImageBase::ST_double, BIAS::ImageBase::ST_float, BIAS::ImageBase::ST_int, BIAS::ImageBase::ST_shortint, BIAS::ImageBase::ST_unsignedchar, BIAS::ImageBase::ST_unsignedint, and BIAS::ImageBase::ST_unsignedshortint.

int ImageIO::ExportImagePnm_ ( const std::string &  FileName,
const ImageBase img,
bool  sync = false,
const bool &  writeMetaData = true 
)
staticprotected
int ImageIO::ExportLibJPEG ( const std::string &  filename,
const BIAS::ImageBase image,
const int  quality = 100 
)
static

Writes an image to disk using the LibJPEG library encapsulated in ExportImage.

Returns
0 in case of success, negative value in case of error.
Parameters
filenamethe filename to write image to
imageis the image to save
qualitydetermines the compression factor used for JPEG (100: no compression, highest quality)
Author
esquivel 05/2008

Definition at line 956 of file ImageIO.cpp.

References BIAS::JpegHandler::Compress(), BIAS::ImageConvert::ConvertST(), BIAS::JpegHandler::Init(), BIAS::JpegHandler::Release(), BIAS::JpegHandler::SetVerbose(), BIAS::ImageBase::ST_unsignedchar, and BIAS::JpegHandler::WriteJPEG().

int ImageIO::ExportMagickPP ( const std::string &  FileName,
const ImageBase  img,
const int &  quality = BIAS_DEFAULT_IMAGE_QUALITY,
const bool &  writeMetaData = false,
const bool &  forceBinaryPNMformat = true,
const bool &  losslesJpgMode = false,
const bool &  writeGZipped = false,
const std::string &  comment = std::string("") 
)
static

Reads an image from disk using the ImageMagick++ library.

Todo:

Implement 16bit short write with Magick++ using BLOB.

Implement quality directive for jpg saving with Magick++.

Bug:
IMageMagick PPM files are alwyas written as ASCII instaed of binary (JW)
Returns
0 in case of succes, negative value in case of error.
Parameters
FileNamethe input filename to read from.
imgcontains the image to be written to disk.
qualityfor saving, e.g.1-100 for jpeg, tested for jpeg. Is overridden by losslessMode parameter
writeMetaDatatry to write ASCII MetaData as comment to file.
forceBinaryPNMformattrue to write BINARY pnm/pbm/pgmp/ppm instead of human readable ASCII.
losslesModetrue to write in jpeg loslles mode. overrides quality setting
writeGZippedtrue for additional gzip compression (e.g. .pgm.gz) which may be useful for human readable ASCII pgm output but save disk space.

Output file type is determined automatically by file extension.

See http://www.imagemagick.org/script/formats.php or

identify
-list format

for supported formats.

Author
Jan Woetzel 10/2004

quality and compession are two different parameters in jpeg but the user usually wants lossles and no compression on lossless flag, so force 100% quality, here:

Comment header is limited to 4096 Bytes for some formats and ASCII BIAS::MetaData representation may be too long to do so!

Examples:
ExampleImageMagickIO.cpp.

Definition at line 1652 of file ImageIO.cpp.

References BIAS::ImageConvert::BIAS2ImageMagick(), BIAS::ImageBase::CM_RGB, BIAS::ImageBase::GetChannelCount(), BIAS::ImageBase::GetHeight(), BIAS::ImageBase::GetMetaData(), BIAS::ImageBase::GetStorageType(), BIAS::ImageBase::GetWidth(), BIAS::ImageBase::Init(), BIAS::FileHandling::LowerCase(), BIAS::ImageBase::Release(), BIAS::ImageBase::SetColorModel(), BIAS::ImageBase::ST_unsignedchar, BIAS::FileHandling::Suffix(), BIAS::ImageConvert::ToRGB(), and BIAS::MetaData::WriteAscii().

int ImageIO::ExportMatrix ( const std::string &  FileName,
const ImageBase img,
const bool  verbose 
)
static

Export BIAS images to text images.

Note
currently only one channel images are supported
  • The format is: cols rows channels interleaved row1 (all channels) row2 ..... .....
See Also
ImportMatrix
Author
Ingo Schiller, moved here from biasconvert
Date
03/2011

Definition at line 1268 of file ImageIO.cpp.

References BIAS::FileHandling::Extension(), BIAS::ImageBase::GetChannelCount(), BIAS::ImageBase::GetHeight(), BIAS::ImageBase::GetImageDataArray(), BIAS::ImageBase::GetStorageType(), BIAS::ImageBase::GetWidth(), BIAS::ImageBase::IsInterleaved(), BIAS::ImageBase::ST_float, and BIAS::ImageBase::ST_unsignedchar.

int ImageIO::ExportOpenCV ( const std::string &  filename,
const ImageBase image 
)
static

Write an image to disk using the OpenCV library.

Parameters
[in]filenameSpecifies the name of the file to write to.
[in]imageContains the image to write.
Returns
Returns 0 in case of success, < 0 in case of errors.
Author
esquivel

Definition at line 286 of file ImageIO.cpp.

References BIAS::WrapBias2Ipl::CreateIplImageShared().

int ImageIO::ExportOpenEXR ( const std::string &  FileName,
const ImageBase input 
)
static

save an .exr OpenEXR image to disk.

Definition at line 355 of file ImageIO.cpp.

References BIAS::OpenEXRInterface::Export().

int BIAS::ImageIO::ExportTIFFLIB ( const std::string &  FileName,
const BIAS::ImageBase img,
const unsigned int  rowsPerStripArg = 0,
const unsigned int  compressionAlgo = BIAS_COMPRESSION_NONE,
const std::string &  comment = std::string("BIAS::ImageIO Jan Woetzel") 
)
static

Write image to disk using TiffLib directly.

Parameters
rowsPerStripArgnr of rows if strip based writing is used in contrast to scanlin or tile based TIFF format. for value 0 the imageheight is used => one big strip.
compressionAlgocompression algorithm to use. better compression = slower. E.g. BIAS_COMPRESSION_LZW or BIAS_COMPRESSION_NONE
Returns
EXIT_SUCCESS on success, other on failure.
Author
Jan Woetzel
Todo:
TODO: do we need to check that rowsPerStrip is modulo image height?

Definition at line 2967 of file ImageIO.cpp.

References BIAS::ImageBase::GetChannelCount(), BIAS::ImageBase::GetDepth(), BIAS::ImageBase::GetHeight(), BIAS::ImageBase::GetImageDataArray(), BIAS::ImageBase::GetWidth(), and BIAS::ImageBase::IsInterleaved().

std::string ImageIO::ExtensionName ( const std::string &  oldName,
const std::string &  newExtension 
)
static

appends extension to name if extension is not already extension, avoids double extension like ".pgm.pgm"

Parameters
oldNamefilename (maybe selected by user)
newExtensiondesired extension
Returns
a filename with extension
Author
Jan Woetzel 04/2003

Definition at line 1072 of file ImageIO.cpp.

References BIAS::FileHandling::DirectoryAndBasename(), BIAS::FileHandling::Extension(), and BIAS::FileHandling::LowerCase().

Referenced by Save(), Write_(), and WriteRAW_IMA().

std::string ImageIO::GetExtension ( const BIAS::ImageIO::TFileFormat fmt)
static

return the default extension for a given FileFormat enum

Author
Jan Woetzel

Definition at line 2499 of file ImageIO.cpp.

BIAS::ImageIO::TFileFormat ImageIO::GetFileFormat ( const std::string &  str)
static

determines the BIAS::ImageIO::TFileFormat for a given filename/ extension Decision based on extension comparison

Author
Jan Woetzel

Definition at line 2543 of file ImageIO.cpp.

References BIAS::FileHandling::Extension(), and BIAS::FileHandling::LowerCase().

int ImageIO::ImportDevIL ( const std::string &  FileName,
ImageBase result,
const unsigned int &  tex3DplaneZ = 1 
)
static

Reads an image from disk using the DevIL/OpenIL library.

See http://openil.sourceforge.net for details. Supports reading multiple formats, including

  • .bmp, .gif, .jpg, .pcd, .pcx, .pic, .png, .pnm
  • .tga, .tif , .io
  • .dds
  • Doom graphics, ... and many other.
Returns
0 in case of succes, negative value in case of error.
Parameters
FileNamethe input filename to read from.
tex3DplaneZignored for tex2D. Useful to extarct 2D texture from volumetric 2D texture.
resultcontains the read image if success.
Author
Jan Woetzel 12/2005

Definition at line 2122 of file ImageIO.cpp.

References BIAS::ImageBase::CM_BGR, BIAS::ImageBase::CM_BGRA, BIAS::ImageBase::CM_Grey, BIAS::ImageBase::CM_GreyA, BIAS::ImageBase::CM_invalid, BIAS::ImageBase::CM_RGB, BIAS::ImageBase::CM_RGBA, BIAS::ImageBase::GetBitDepth(), BIAS::ImageBase::GetChannelCount(), BIAS::ImageBase::GetDepth(), BIAS::ImageBase::GetImageData(), BIAS::ImageBase::GetPixelCount(), BIAS::ImageBase::Init(), BIAS::ImageBase::IsEmpty(), BIAS::ImageBase::Release(), BIAS::ImageBase::SetColorModel(), BIAS::ImageBase::ST_char, BIAS::ImageBase::ST_double, BIAS::ImageBase::ST_float, BIAS::ImageBase::ST_int, BIAS::ImageBase::ST_invalid, BIAS::ImageBase::ST_shortint, BIAS::ImageBase::ST_unsignedchar, BIAS::ImageBase::ST_unsignedint, BIAS::ImageBase::ST_unsignedshortint, and BIAS::ImageBase::UpdateImageDataArrayFromImageData_().

int ImageIO::ImportImage ( const std::string &  filename,
ImageBase result 
)
static

Try to load/import an image from a file using external libs.

Formats supported are listed in TFileFormat. More over a few other formats may be includeable like GIF. The imported image is always of the type RGB.

Parameters
filenamename of the file to be loaded
Returns
-1 in case of error
UNKNOWN_META_DATA if meta data could not be read param assumeGrey : DEPRECATED. Was used to speed up loading with imlib
Author
Ingo Thomsen 2002 - Complete Rewrite by Jan Woetzel 2005
Examples:
ExampleCamera.cpp, ExampleCondensHisto.cpp, ExampleConvertHDR.cpp, ExampleDeInterlace.cpp, ExampleHistogram.cpp, and ExampleMetaData.cpp.

Definition at line 378 of file ImageIO.cpp.

References BIAS::ImageBase::CM_Grey, BIAS::ImageBase::CM_RGB, BIAS::MetaData::Find(), BIAS::ImageBase::GetMetaData(), BIAS::ImageBase::InvalidateUID(), BIAS::AppData::MD_USE_ASCII, BIAS::AppData::MD_UUID, BIAS::AppData::sdata, BIAS::ImageBase::SetColorModel(), BIAS::ImageBase::SetUID(), and BIAS::AppData::tag.

Referenced by Load().

int ImageIO::ImportImagePnm_ ( std::ifstream &  ifs,
ImageBase result,
int  depth 
)
staticprotected
int ImageIO::ImportImageViff_ ( std::ifstream &  ifs,
ImageBase result 
)
staticprotected

import a one channel grey float viff image (Khoros image format) for compatibility to old stereo code

Parameters
FileNamedestination filename
imgBIAS ImageBase to be written to disk
Author
Jan Woetzel 01/2003

Definition at line 1386 of file ImageIO.cpp.

References BIAS::ImageBase::CM_Grey, xvimage::col_size, BIAS::ImageBase::GetImageData(), BIAS::ImageBase::GetSizeByte(), BIAS::ImageBase::Init(), BIAS::ImageBase::IsEmpty(), BIAS::ImageBase::Release(), xvimage::row_size, BIAS::ImageBase::SetColorModel(), and BIAS::ImageBase::ST_float.

int ImageIO::ImportLibJPEG ( const std::string &  filename,
BIAS::ImageBase result,
bool  readComment = true 
)
static

Reads an image from disk using the LibJPEG library encapsulated in ImportImage.

Returns
0 in case of success, negative value in case of error.
Parameters
filenamethe input filename to read from.
resultis the returned read image
readCommentspecifies if comment metadata should be read
Author
esquivel 05/2008

Definition at line 540 of file ImageIO.cpp.

References BIAS::JpegHandler::Decompress(), BIAS::JpegHandler::Init(), BIAS::ImageBase::IsEmpty(), BIAS::JpegHandler::ReadJPEG(), BIAS::JpegHandler::Release(), BIAS::ImageBase::Release(), and BIAS::JpegHandler::SetVerbose().

int ImageIO::ImportMagickPP ( const std::string &  FileName,
ImageBase result,
const bool &  dummy = false,
const bool &  readMetaData = true 
)
static

Reads an image from disk using the ImageMagick++ library.

is called automatically by ImportImage.

Parameters
dummyignored, for consistency with ImportMagickPPAutoconvert
readMetaDatatrue to try to read metadat (from comment field)
Returns
0 in case of succes, negative value in case of error.
Todo:
fix the error on reading reference streaming in Metadata operator>> e.g. on loading ibak "M34/Front/image00000000.jpg" (jw)
Author
jw and woelk 12/2004

Definition at line 193 of file ImageIO.cpp.

References BIAS::MetaData::Add(), BIAS::ImageBase::GetMetaData(), and BIAS::ImageConvert::ImageMagick2BIAS().

int ImageIO::ImportMagickPPAutoconvert ( const std::string &  FileName,
ImageBase result,
const bool &  assumeGrey = false,
const bool &  readMetaData = false 
)
static

Reads an image from disk using the ImageMagick++ library.

: This routine is working inefficiently, because it doesn't know what to do about conversion if read and requested types don't match (10/2004) However it works and assumes RGB in case of doubt.

Todo:
Implement assumeGrey for MagickPP like for Imlib (JW).

result image must be initialized. Thread image is automatically converted to match the result image.

Returns
0 in case of succes, negative value in case of error.
Parameters
FileNamethe input filename to read from.
imgcontains the read image if success.
assumeGreynot implemented for now, just for interface compatibility with Bias Import functions
readMetaDatatry to read ASCII metadata from file comment.

See http://www.imagemagick.org/script/formats.php for supported formats.

Author
Jan Woetzel 10/2004
Todo:
rewrite by making more use of type Image<..> instead of ImageBase because lossless conversions and warnings for unwanted lossy conversions are easier, then.
Author
Jan Woetzel 10/2004

keep the output storagetype

Todo:
TODO HACK add dynamic cast test for templated Image<> to convert loaded float image automatically to uc etc..
Todo:
add more knowledge about conversion and the option of errors if requested and read type don't match. check if at least StorageType and bit depth match:
Todo:
handle conversion in extra routine with extra warnings in case of scaling or lossy conversion. -Add a 'normalized scale' per conversion for each Storagetype. -Add a flag to return errors instead of run-time warning. (discussion 26.Oct.2004)
Todo:
float and double pixel are 0..1 normalized range in ImageMagick++. Min, max meta data required
Examples:
ExampleImageMagickIO.cpp.

Definition at line 1450 of file ImageIO.cpp.

References BIAS::ImageBase::CM_BGR, BIAS::ImageBase::CM_Grey, BIAS::ImageBase::CM_GreyA, BIAS::ImageBase::CM_invalid, BIAS::ImageBase::CM_RGB, BIAS::ImageBase::CM_RGBA, BIAS::ImageBase::GetColorModel(), BIAS::ImageBase::GetHeight(), BIAS::ImageBase::GetImageData(), BIAS::ImageBase::GetStorageType(), BIAS::ImageBase::GetWidth(), BIAS::ImageBase::Init(), BIAS::ImageBase::IsEmpty(), BIAS::ImageBase::Release(), BIAS::ImageBase::SetColorModel(), BIAS::ImageBase::ST_char, BIAS::ImageBase::ST_double, BIAS::ImageBase::ST_float, BIAS::ImageBase::ST_int, BIAS::ImageBase::ST_invalid, BIAS::ImageBase::ST_shortint, BIAS::ImageBase::ST_unsignedchar, BIAS::ImageBase::ST_unsignedint, and BIAS::ImageBase::ST_unsignedshortint.

int ImageIO::ImportMatrix ( const std::string &  FileName,
ImageBase img,
const bool  verbose 
)
static

Import text images to BIAS.

The format is: cols rows channels interleaved row1 (all channels) row2 ..... .....

See Also
ExportMatrix
Author
Ingo Schiller, moved here from biasconvert
Date
03/2011

Definition at line 1232 of file ImageIO.cpp.

References BIAS::FileHandling::Extension(), BIAS::ImageBase::GetImageDataArray(), BIAS::ImageBase::Init(), and BIAS::ImageBase::ST_float.

int ImageIO::ImportOpenCV ( const std::string &  filename,
ImageBase image 
)
static

Reads an image from disk using the OpenCV library.

Parameters
[in]filenameSpecifies the name of the file to read from.
[out]imageReturns the image read from file if successful.
Returns
Returns 0 in case of success, < 0 in case of errors.
Author
Jan Woetzel

Definition at line 256 of file ImageIO.cpp.

References BIAS::WrapBias2Ipl::CreateBiasImageCopy().

int ImageIO::ImportOpenEXR ( const std::string &  FileName,
ImageBase result 
)
static

load an .exr OpenEXR image from disk.

Definition at line 365 of file ImageIO.cpp.

References BIAS::OpenEXRInterface::Import().

int BIAS::ImageIO::ImportRADIANCE ( const std::string &  FileName,
ImageBase result 
)
static

import Greg Wards Radiance RGBE image format (.hdr, .rad) A high dynamic range RGBE image contains 24 bits RGB Mantissa and 8 common exponent bits that encode the dynamic range.

See http://radsite.lbl.gov/radiance/ Own implementation just for copyright reasons.

Author
Jan Woetzel 01/2006
Todo:
: decode the runlength encode line, map the RGBE to float or do it in ColorConverion?

Definition at line 2624 of file ImageIO.cpp.

References BIAS::ImageBase::GetImageDataArray(), BIAS::ImageBase::Init(), BIAS::ImageBase::IsEmpty(), BIAS::ImageBase::Release(), and BIAS::ImageBase::ST_unsignedchar.

int ImageIO::ImportRAWwithHeader ( const std::string &  filename,
BIAS::ImageBase img 
)
static

Reads a proprietary .RAW format from disk A typical file consists of these blocks:

  • magick cookie + HEADER size - 7 Byte, e.g. "RAW4096" thus magick cookies are "RAW8", "RAW4", "RAW2" ,"RAW1", "RAW0" for 8192, 4096, 2048, 1024, 0512 Byte header inclufing cookie.

E.g. RAW4096 is 4096 Byte text header followed by arbitrary size RAW datat specicified in the header. Used for most efficient write to disk on WIN32 using system calls without buffering and cache with DMA. E.g:

Block Name - 4 Byte - RAW8[192] / RAW4[096] /RAW2[048]
/RAW1[024] / RAW0[512]
Block Length - 3/4 Byte - 8192/192 4096/096 should be 4 Byte but
is 3 Byte in old RAW4096 fmt witten for "Mediendom" project.
Block Data - binary data area begins at Byte nr. "block length+1",
e.g. 4096+1 from the begginning of file, including header.

TODO: encode header information in Write routine compatible to digital cameras .raw format which is very similar.

FYI: IrFanView can read and display this format natively (on WIN32).

Inspired by http://www.dalibor.cz/minolta/raw_file_format.htm and the need to write exactly on aligned memory and disk block sizes for performance reasons, in particular on WIN32.

Works only with 8 bpp one plane Bayer pattern raw images (from scorpion camera) actually.

Bug:
Reading the data on Linux is broken because fopen ignores the binary flag, see "man fopen".
Returns
0 in case of succes, negative value in case of error.
Author
Jan Woetzel 2005
Examples:
ExampleConvertRAW.cpp.

Definition at line 1791 of file ImageIO.cpp.

References BIAS::ImageBase::CM_Bayer_RGGB, BIAS::ImageBase::CopyIn_NoInit(), BIAS::ImageBase::Init(), BIAS::ImageBase::IsEmpty(), BIAS::ImageBase::Release(), and BIAS::ImageBase::SetColorModel().

int BIAS::ImageIO::ImportReal32 ( const std::string &  FileName,
ImageBase result 
)
static

Loads proprietary raw floating point 2d image from Mathematica Real32 values Example how to export in Mathematica:

(* helper functions *)
Header[img_] := ({1, Dimensions[img][[1]], Dimensions[img][[2]], 1})
ExportReal32[filename_, img_] := Export[filename <> ".real32",
Append[Header[img], img], "Real32"]

(* sample data *)
img = {
{1.1, 2.2},
{3.3, 4.4},
{5.5, 6.6} };

(* final usage writing to disk in appropriate format: *)
ExportReal32["out_img", img]
Author
Jan Woetzel

Definition at line 2788 of file ImageIO.cpp.

References BIAS::ImageBase::GetImageData(), BIAS::ImageBase::Init(), BIAS::ImageBase::IsEmpty(), BIAS::ImageBase::Release(), and BIAS::ImageBase::ST_float.

int BIAS::ImageIO::ImportTIFFLIB ( const std::string &  FileName,
ImageBase img 
)
static

read a tiff image from disk using TiffLib directly

Author
Jan Woetzel

Definition at line 3092 of file ImageIO.cpp.

void ImageIO::InitDevIL ( )
static

initialize devIL once globally.

Usually called by IL load and save functions automatically. To speed up first load/save you can "pre-call" it on startup.

Author
Jan Woetzel

Definition at line 2043 of file ImageIO.cpp.

int ImageIO::Load ( const std::string &  FileName,
ImageBase img 
)
static

first tries a call to Read MIP image and if that fails, tries to Import Image with all other available format loaders and third party libraries.

Note: Win32 paths such as "C:/data/image.jpg" will work, backslashes not because they escape chars.

Returns
0 on success
UNKNOWN_META_DATA if meta data could not be read
Author
Felix Woelk, Jan Woetzel
Examples:
EvaluateAlignment.cpp, ExampleAffineMappingScaleOnly.cpp, ExampleAlignment.cpp, ExampleBilateral.cpp, ExampleBinomial.cpp, ExampleBlobDetectorBFS.cpp, ExampleBlobDetectorCCA.cpp, ExampleCalibratedPyramid.cpp, ExampleCamera.cpp, ExampleColorNCC.cpp, ExampleCondensHisto.cpp, ExampleConstantRegion.cpp, ExampleContourDetectorBSpline.cpp, ExampleContourDetectorSimple.cpp, ExampleConvert.cpp, ExampleConvertBayerPattern.cpp, ExampleCornerDetector.cpp, ExampleCylinderMapping.cpp, ExampleDeInterlace.cpp, ExampleDeInterlace2.cpp, ExampleDilation.cpp, ExampleDistTransform.cpp, ExampleEmpty.cpp, ExampleErosion.cpp, ExampleExtractKFromMipImage.cpp, ExampleGauss.cpp, ExampleGradient.cpp, ExampleHarrisColor.cpp, ExampleHistogramEqualization.cpp, ExampleHomographyMapping.cpp, ExampleHSVConversion2.cpp, ExampleImageCanvas.cpp, ExampleImageCanvasFloat.cpp, ExampleImageDiff.cpp, ExampleImageDri.cpp, ExampleImageLoad.cpp, ExampleInterpolation.cpp, ExampleIpl.cpp, ExampleIplImageDisplay.cpp, ExampleIplImageDraw.cpp, ExampleIplWrapOpenCV.cpp, ExampleJPEGCompress.cpp, ExampleLEDDetector.cpp, ExampleLineMatcher.cpp, ExampleLogPolarMapping.cpp, ExampleMedian.cpp, ExampleMedian3x3x3.cpp, ExampleMetaData.cpp, ExampleParabola.cpp, ExamplePlainPerPixelProcessing.cpp, ExamplePMDImageIO.cpp, ExampleProjectionMapping.cpp, ExamplePyramidImage.cpp, ExampleRefineContour.cpp, ExampleRemoveSaltAndPepper.cpp, ExampleRescale.cpp, ExampleROI.cpp, ExampleROIImage.cpp, ExampleStructureTensor.cpp, ExampleTile.cpp, ExampleToPlanar.cpp, ExampleTracker.cpp, ExampleTrackerBase.cpp, ExampleTrackerBaseInterface.cpp, ExampleTransformToCartesian.cpp, ExampleUndistort.cpp, and ExampleUpsampleBy2Grey.cpp.

Definition at line 141 of file ImageIO.cpp.

References BIAS::FileHandling::FilenameExpansion(), BIAS::FileHandling::GetCwd(), and ImportImage().

Referenced by BIAS::VideoSink_FFmpeg::AddFrame(), BIAS::ImgObjGL::CreateGLCubemap(), BIAS::VideoSource_Disk_Bayer::GrabSingle(), BIAS::VideoSource_DiskZessPMD::GrabSingle(), BIAS::VideoSource_Disk::GrabSingle(), BIAS::IOUtils::LoadCamera(), BIAS::IOUtils::LoadImageList(), BIAS::CylindricDepthTrackingPanorama::LoadPanorama(), BIAS::VideoSource_Disk_Bayer::OpenDevice(), BIAS::VideoSource_DiskZessPMD::OpenDevice(), BIAS::VideoSource_Disk::OpenDevice(), BIAS::SceneTexturedPlane::SetImage(), BIAS::ShowCamWxFrame::ShowCamWxFrame(), BIAS::glfCubeMap::UploadImageFromFile(), and BIAS::glfTexture2D::UploadImageFromFile().

int ImageIO::ParseRAWwithHeader ( const std::string &  buf,
const std::string &  tag,
unsigned int &  retVal 
)
static

helper function for ImportRAWwithHeader Parses buf for tag

Returns
retVal value associated to tag in buf
Author
Jan Woetzel 2005

Definition at line 1922 of file ImageIO.cpp.

void ImageIO::PrintInfoDevIL ( std::ostream &  os = std::cout)
static

print info in currently bound DevIL image

Author
Jan Woetzel

Definition at line 2085 of file ImageIO.cpp.

int ImageIO::Read_ ( const std::string &  FileName,
ImageBase img 
)
staticprotected

Read a proprietary mip binary Image from disk and allocate memory structure.

Please note the more general purpose Load/Save interface you may want to use instead.

Parameters
FileNamecomplete name of file to be loaded
imgobject to receive the image data fro the file
idThe image is assigned id if there is no id in the file
Author
Felix Woelk

Definition at line 1341 of file ImageIO.cpp.

References BIAS::ImageBase::GetMetaData().

int ImageIO::Save ( const std::string &  filename,
const ImageBase img,
const enum TFileFormat  FileFormat = FF_auto,
const bool  sync = BIAS_DEFAULT_SYNC,
const int  c_jpeg_quality = BIAS_DEFAULT_IMAGE_QUALITY,
const bool  forceNewID = BIAS_DEFAULT_FORCENEWID,
const bool &  writeMetaData = true 
)
static

Export image as file using extrnal libs.

Parameters
filenamename of the file to be loaded
imgImage to be saved, not const because of setUUID side effect.
FileFormatWhat file format shall be used for saving
jpeg_qualityQuality of a jpeg image to be saved, unused in all other formats
syncdoes only worlk with pgm/ppm (woelk)
writeMetaDatatrue to (try to) write meta data to disk and false to drop it.
Returns
0 on success
Author
(Ingo Thomsen) - complete rewrite by Jan Woetzel
Examples:
EvaluateAlignment.cpp, ExampleAffineMappingScaleOnly.cpp, ExampleAlignment.cpp, ExampleBilateral.cpp, ExampleBinomial.cpp, ExampleBlobDetectorBFS.cpp, ExampleBlobDetectorCCA.cpp, ExampleBresenham.cpp, ExampleBSplineCurve.cpp, ExampleCamera.cpp, ExampleChessboard.cpp, ExampleCMU1394.cpp, ExampleColorNCC.cpp, ExampleCondensHisto.cpp, ExampleCondensImg.cpp, ExampleConic.cpp, ExampleConstantRegion.cpp, ExampleContextWx.cpp, ExampleContourDetectorSimple.cpp, ExampleConvert.cpp, ExampleConvertBayerPattern.cpp, ExampleConvertHDR.cpp, ExampleCornerDetector.cpp, ExampleCylinderMapping.cpp, ExampleDataPlot.cpp, ExampleDC1394.cpp, ExampleDcam.cpp, ExampleDcamImageConvert.cpp, ExampleDeInterlace.cpp, ExampleDeInterlace2.cpp, ExampleDilation.cpp, ExampleDistTransform.cpp, ExampleDraw.cpp, ExampleDrawConic.cpp, ExampleDrawLines.cpp, ExampleDrawTextWx.cpp, ExampleErosion.cpp, ExampleForeignData.cpp, ExampleGauss.cpp, ExampleGenSynthMatches.cpp, ExampleGenSynthMatchesRig.cpp, ExampleGrabTrippleFromXB3.cpp, ExampleGradient.cpp, ExampleHarrisColor.cpp, ExampleHistogram.cpp, ExampleHistogramEqualization.cpp, ExampleHomographyMapping.cpp, ExampleHSVConversion.cpp, ExampleHSVConversion2.cpp, ExampleImageDiff.cpp, ExampleImageDri.cpp, ExampleImageMagickIO.cpp, ExampleImageOperator.cpp, ExampleInterpolation.cpp, ExampleIpl.cpp, ExampleIplImageDraw.cpp, ExampleIplWrapOpenCV.cpp, ExampleLEDDetector.cpp, ExampleLineMatcher.cpp, ExampleLogPolarMapping.cpp, ExampleMedian.cpp, ExampleMedian3x3x3.cpp, ExampleMetaData.cpp, ExampleMinMax.cpp, ExampleMixtureOfGaussians.cpp, ExampleMultipleDcams.cpp, ExampleParabola.cpp, ExamplePlainPerPixelProcessing.cpp, ExamplePMDImageIO.cpp, ExampleProjectionMapping.cpp, ExampleProjectionParametersPerspective.cpp, ExamplePtGreyHiresColor.cpp, ExampleRefineContour.cpp, ExampleRemoveSaltAndPepper.cpp, ExampleRescale.cpp, ExampleROI.cpp, ExampleROIImage.cpp, ExampleStructureTensor.cpp, ExampleTFT.cpp, ExampleTile.cpp, ExampleToPlanar.cpp, ExampleTracker.cpp, ExampleTrackerBase.cpp, ExampleTrackerBaseInterface.cpp, ExampleTransformToCartesian.cpp, ExampleUndistort.cpp, ExampleUpsampleBy2Grey.cpp, ExampleVideoSource_Net.cpp, and ExampleVideoSource_Shm.cpp.

Definition at line 725 of file ImageIO.cpp.

References BIAS::MetaData::Add(), ExtensionName(), BIAS::FileHandling::FilenameExpansion(), BIAS::UUID::GenerateUUID(), BIAS::ImageBase::GetChannelCount(), BIAS::ImageBase::GetDepth(), BIAS::ImageBase::GetMetaData(), BIAS::ImageBase::GetStorageType(), BIAS::UUID::GetString(), BIAS::ImageBase::GetUID(), BIAS::ImageConvert::IP_ToGrey(), BIAS::UUID::IsValid(), BIAS::ImageBase::SetUID(), and BIAS::ImageBase::ST_invalid.

Referenced by BIAS::CornerDetectorGradient< StorageType, CalculationType >::_CalcCornerness(), BIAS::LinearRegionDetector< StorageType, CalculationType >::_ComputeCornerness(), BIAS::CornerDetectorKLT< StorageType, CalculationType >::_ComputeCornerness(), BIAS::StructureTensor< InputStorageType, OutputStorageType >::_WriteDebugImage(), BIAS::ThreeDOutOpenSceneGraph::AddOSGImage_(), BIAS::ImageAlignment::Align(), BIAS::MixtureOfGaussians< StorageType >::Apply(), BIAS::StructureTensor< InputStorageType, OutputStorageType >::CalcStructureTensor(), BIAS::clfUnifiedMultilateralFilter::Compute(), BIAS::CornerDetectorGradient< StorageType, CalculationType >::Detect(), BIAS::RectificationViaProjectionMappingBase< InputStorageType, OutputStorageType >::Disp2Depth(), BIAS::glfTexture2D::DumpUC_RGBA(), BIAS::Binomial< InputStorageType, OutputStorageType >::Filter3x3ValidGreyFloat(), BIAS::Binomial< InputStorageType, OutputStorageType >::Filter5x5ValidGreyFloat(), BIAS::Convolution< InputStorageType, OutputStorageType >::FilterFloat(), BIAS::Convolution< InputStorageType, OutputStorageType >::FilterInt(), BIAS::CylindricDepthTrackingPanorama::GetTriangleMesh(), BIAS::SphericalDepthPanorama::GetTriangleMesh(), BIAS::CylindricDepthPanorama::GetTriangleMesh(), BIAS::ImageLegendFrame::OnSave(), BIAS::ExampleMixtureOfGaussiansFrame::OnTimer(), BIAS::Tracker< StorageType, CalculationType >::PreparePyramide(), BIAS::CylindricDepthPanorama::ProcessCylindricProjection(), BIAS::IOUtils::SaveCamera(), BIAS::FilterDialogBase< InputST, OutputST >::SaveFilteredImage(), BIAS::ShowCamWxFrame::SaveImageUnthreaded_(), BIAS::CylindricDepthTrackingPanorama::SavePanorama(), BIAS::OpenGLCanvasBase::ScreenShot(), BIAS::ScreenShotListener::StoreNextScreenShot_(), BIAS::Tracker< StorageType, CalculationType >::Track(), BIAS::TrackerBaseAffine< StorageType >::TrackAffine_(), BIAS::TrackerBaseAffine2< StorageType >::TrackAffine_(), and BIAS::ThreeDOut::VRMLOutIndexedFaceSets().

int ImageIO::Write_ ( const std::string &  FileName,
const ImageBase img,
const bool  sync = false,
const bool  forceNewID = true 
)
staticprotected

Write a proprietary mip binary Image to disk.

Please note the more general purpose Load/Save interface you may want to use instead.

Parameters
FileNameoutput file name. Extension .mip is added if extension isn't already (case insensitive) 'mip' (JW 04/2003)
Author
Felix Woelk
Parameters
synctries to flush all open buffers/caches

Definition at line 1096 of file ImageIO.cpp.

References ExtensionName(), BIAS::UUID::GenerateUUID(), BIAS::ImageBase::GetMetaData(), BIAS::ImageBase::GetUID(), BIAS::UUID::IsValid(), BIAS::ImageBase::SetUID(), and BIAS::MetaData::WriteBinary().

int ImageIO::WriteRAW_IMA ( const std::string &  FileName,
const ImageBase img_const 
)
static

Write image in binary file format needed by RealEyes.

Author
bartczak 03/2008

Definition at line 1173 of file ImageIO.cpp.

References ExtensionName(), BIAS::ImageBase::GetChannelCount(), BIAS::ImageBase::GetHeight(), BIAS::ImageBase::GetImageData(), BIAS::ImageBase::GetWidth(), and BIAS::ImageBase::IsInterleaved().

int ImageIO::WriteUnbuffered ( const std::string &  FileName,
const ImageBase img 
)
static

Write a mip binary image to disk circumventing OS caches as good as possible.

(O_DIRECT)

Author
Jan-Friso Evers
Examples:
ExampleDraw.cpp.

Definition at line 1975 of file ImageIO.cpp.

References BIAS::UUID::GenerateUUID(), BIAS::ImageBase::GetMetaData(), BIAS::ImageBase::GetUID(), BIAS::UUID::IsValid(), BIAS::ImageBase::SetUID(), and BIAS::MetaData::WriteBinary().

Member Data Documentation

char * ImageIO::MemAlignedBuffer_ = NULL
staticprotected

Definition at line 566 of file ImageIO.hh.

unsigned long int ImageIO::MemAlignedBufferSize_ = 0
staticprotected

Definition at line 567 of file ImageIO.hh.


The documentation for this class was generated from the following files: