STIRA  0.1
Public Types | Public Member Functions | Static Public Member Functions | List of all members
stira::imagetools::ImageIO Class Reference

A class to hold spectral bands of an image. More...

#include <ImageIO.h>

Public Types

enum  outputType {
  NULL_OUT, GRADIENT_OUT, NORMAL_OUT, LOG_OUT,
  ABSOLUTE_NORM_OUT, ABSOLUTE_POS_OUT, ABSOLUTE_NEG_OUT
}
 type to identify how the image intensities need to be rescaled for export More...
 

Public Member Functions

 ImageIO ()
 Constructor.
 
 ~ImageIO ()
 Destructor.
 

Static Public Member Functions

static ImageRead (std::string fname)
 reads a file using the correct input help method More...
 
static ArrayGrid< int > * ReadPGMasInt (std::string fname)
 reads an image as a grid of integers More...
 
static bool Write (Image *pImage, std::string fname, outputType outtype=NULL_OUT)
 determines whether image object has 1 or three bands and then writes image with appropriate method to file More...
 
static void WritePGM (ArrayGrid< std::complex< double > > *pGrid, std::string fileName, outputType outtype=NULL_OUT)
 writes an ArrayGrid of complex doubles from memory to disk . It writes two files: one containing all the real values, one containing all the imaginary values More...
 
static bool WritePGM (ArrayGrid< double > *pGrid, std::string fileName, outputType outtype=NULL_OUT)
 writes an ArrayGrid of doubles from memory to disk . More...
 
static bool WritePGM (ArrayGrid< int > *pGrid, std::string fileName, outputType outtype=NULL_OUT)
 writes an ArrayGrid of integers from memory to disk . More...
 
static bool WritePGM (ArrayGrid< bool > *pGrid, std::string fileName)
 writes an ArrayGrid of booleans from memory to disk . More...
 
static bool WriteTXT (ArrayGrid< double > *pGrid, std::string fileName)
 writes an ArrayGrid of doubles from memory to disk in a simple text file. More...
 
static double GetOpenCvGrayValue (IplImage *pIplImage, int x, int y)
 gets an intensity of an OpenCV image assuming it is a gray value More...
 
static void SetOpenCvGrayValue (IplImage *pIplImage, int x, int y, double value)
 sets the intensity at position (x,y) in an OpenCV image assuming it is a gray value More...
 
static double GetOpenCvColorValue (IplImage *pIplImage, int x, int y, int bandNr)
 gets an intensity at position (x,y) in an OpenCV image in the specified color band More...
 
static void SetOpenCvColorValue (IplImage *pIplImage, int x, int y, int bandNr, double value)
 sets an intensity at position (x,y) in an OpenCV image in the specified color band More...
 
static ArrayGrid< double > * ConvertOpenCvToDoubleArrayGrid (IplImage *pIplImage)
 
static ArrayGrid< double > * ConvertOpenCvToDoubleArrayGrid (IplImage *pIplImage, ArrayGrid< double > *pGrid)
 
static ArrayGrid< bool > * ConvertOpenCvToBooleanArrayGrid (IplImage *pIplImage, double threshold=0)
 
static IplImage * ConvertArrayGridToOpenCv (ArrayGrid< double > *pGridIn, IplImage *pImgOut)
 
static ImageConvertOpenCvToImage (IplImage *pIplImage)
 converts an OpenCV image structure to our library image class More...
 
static IplImage * ConvertImageToOpenCv (Image *pImage)
 converts object of our own image class into an OpenCV image structure More...
 
static ImageReadImageOpenCV (std::string fname, bool useROI=false, common::RectangularROI< int > myImageROI=common::RectangularROI< int >(0, 0, 0, 0))
 reads an image from a disk file using OpenCVuseBGR More...
 
static ArrayGrid< double > * ReadArrayOpenCVAsDouble (std::string fname, ArrayGrid< double > *pGrid=0, bool useROI=false, common::RectangularROI< int > myImageROI=common::RectangularROI< int >(0, 0, 0, 0))
 reads a single band of an image from a disk file using OpenCV More...
 
static ArrayGrid< int > * ReadArrayOpenCVAsInt (std::string fname, bool useROI=false, common::RectangularROI< int > myImageROI=common::RectangularROI< int >(0, 0, 0, 0))
 reads a single band of an image from a disk file using OpenCV More...
 
static bool WriteOpenCV (Image *pImage, std::string fname, outputType outtype=NORMAL_OUT)
 writes an image object to a disk file More...
 
static bool WriteOpenCV (ArrayGrid< double > *pGrid, std::string fname, outputType outtype=NORMAL_OUT)
 writes a single grid object of double precision float values to a disk file More...
 
static bool WriteOpenCV (ArrayGrid< int > *pGrid, std::string fname, outputType outtype=NORMAL_OUT)
 writes a single grid object of integer values to a disk file More...
 
static bool WriteOpenCV (ArrayGrid< bool > *pGrid, std::string fname)
 writes a single grid object of booleans to a disk file More...
 
static void GetInputMinMax (ArrayGrid< double > *pGrid, double &mmin, double &mmax, outputType myType=NULL_OUT)
 gets minimum and maximum value of values in pGrid, or of function of values in pGrid (abs(intensity), log(intensity), ...) More...
 
static bool RescaleGrid (ArrayGrid< double > *pGrid, outputType outtype=NULL_OUT)
 Rescales the values in a real-valued grid according to type outtype More...
 

Detailed Description

A class to hold spectral bands of an image.

Member Enumeration Documentation

type to identify how the image intensities need to be rescaled for export

Enumerator
NULL_OUT 

no rescaling applied; just use input values

GRADIENT_OUT 

gradient type: zero is grey, negative goes from grey to black, positive values go from grey to white

NORMAL_OUT 

only positive values: linear scaling

LOG_OUT 

take logarithm and rescale linearly

ABSOLUTE_NORM_OUT 

take absolute values and rescale linearly

ABSOLUTE_POS_OUT 

take absolute values and rescale linearly

ABSOLUTE_NEG_OUT 

take absolute values and rescale linearly

Member Function Documentation

IplImage * stira::imagetools::ImageIO::ConvertImageToOpenCv ( Image pImage)
static

converts object of our own image class into an OpenCV image structure

Parameters
pImageobject of our own image class
Returns
OpenCV image structure

References stira::imagedata::Image::GetBands(), stira::imagedata::Image::GetHeight(), stira::imagedata::Image::GetNumberOfBands(), and stira::imagedata::Image::GetWidth().

Image * stira::imagetools::ImageIO::ConvertOpenCvToImage ( IplImage *  pIplImage)
static

converts an OpenCV image structure to our library image class

Parameters
pIplImageinput OpenCV image structure
Returns
object of our own image class

References stira::imagedata::Image::GetBands().

void stira::imagetools::ImageIO::GetInputMinMax ( ArrayGrid< double > *  pGrid,
double &  mmin,
double &  mmax,
outputType  myType = NULL_OUT 
)
static

gets minimum and maximum value of values in pGrid, or of function of values in pGrid (abs(intensity), log(intensity), ...)

Parameters
pGridinput grid
mminoutput value with minimum
mmaxoutput value with maximum
myTypetype of function to apply to grid values before comparing them

References stira::imagedata::ArrayGrid< T >::GetHeight(), stira::imagedata::ArrayGrid< T >::GetValue(), and stira::imagedata::ArrayGrid< T >::GetWidth().

double stira::imagetools::ImageIO::GetOpenCvColorValue ( IplImage *  pIplImage,
int  x,
int  y,
int  bandNr 
)
static

gets an intensity at position (x,y) in an OpenCV image in the specified color band

Parameters
pIplImageOpenCV image to read from
xx coordinate to read from
yy coordinate to read from
bandNrnumber of the color band to read the value from
double stira::imagetools::ImageIO::GetOpenCvGrayValue ( IplImage *  pIplImage,
int  x,
int  y 
)
static

gets an intensity of an OpenCV image assuming it is a gray value

Parameters
pIplImageOpenCV image to read from
xx coordinate to read from
yy coordinate to read from
Image * stira::imagetools::ImageIO::Read ( std::string  fname)
static

reads a file using the correct input help method

Parameters
fnamename of the file to read from
ArrayGrid< double > * stira::imagetools::ImageIO::ReadArrayOpenCVAsDouble ( std::string  fname,
ArrayGrid< double > *  pGrid = 0,
bool  useROI = false,
common::RectangularROI< int >  myImageROI = common::RectangularROI<int>( 0, 0, 0, 0) 
)
static

reads a single band of an image from a disk file using OpenCV

Parameters
fnamethe name of the file to read from
pGridpointer to output grid; will create a new grid if NULL
useROIflag whether to read the whole image or an ROI of the image
myImageROIif useROI is true, only image data within this ROI will read from the image
Returns
image object containing the data

References stira::common::RectangularROI< T >::GetBottomRightCorner(), stira::common::RectangularROI< T >::GetTopLeftCorner(), stira::imagedata::ArrayGrid< T >::SetValue(), stira::common::Point< T >::x, and stira::common::Point< T >::y.

ArrayGrid< int > * stira::imagetools::ImageIO::ReadArrayOpenCVAsInt ( std::string  fname,
bool  useROI = false,
common::RectangularROI< int >  myImageROI = common::RectangularROI<int>( 0, 0, 0, 0) 
)
static

reads a single band of an image from a disk file using OpenCV

Parameters
fnamethe name of the file to read from
useROIflag whether to read the whole image or an ROI of the image
myImageROIif useROI is true, only image data within this ROI will read from the image
Returns
image object containing the data

References stira::common::RectangularROI< T >::GetBottomRightCorner(), stira::common::RectangularROI< T >::GetTopLeftCorner(), stira::imagedata::ArrayGrid< T >::SetValue(), stira::common::Point< T >::x, and stira::common::Point< T >::y.

Image * stira::imagetools::ImageIO::ReadImageOpenCV ( std::string  fname,
bool  useROI = false,
common::RectangularROI< int >  myImageROI = common::RectangularROI<int>( 0, 0, 0, 0) 
)
static

reads an image from a disk file using OpenCVuseBGR

Parameters
fnamethe name of the file to read from
useROIflag whether to read the whole image or an ROI of the image
myImageROIif useROI is true, only image data within this ROI will read from the image
Returns
image object containing the data

References stira::imagedata::Image::GetBands(), stira::common::RectangularROI< T >::GetBottomRightCorner(), stira::common::RectangularROI< T >::GetTopLeftCorner(), stira::common::Point< T >::x, and stira::common::Point< T >::y.

ArrayGrid< int > * stira::imagetools::ImageIO::ReadPGMasInt ( std::string  fname)
static

reads an image as a grid of integers

Parameters
fnamename of the file to read from

References stira::imagedata::Image::GetBands(), stira::imagedata::Image::SetImageName(), and stira::imagedata::ArrayGrid< T >::SetValue().

bool stira::imagetools::ImageIO::RescaleGrid ( ArrayGrid< double > *  pGrid,
outputType  outtype = NULL_OUT 
)
static

Rescales the values in a real-valued grid according to type outtype

Warning
operates on pGrid values; values before rescaling are lost
Parameters
pGridArrayGrid object of which values needed to be rescaled
outtypetype of rescaling to apply before writing to disk

References stira::imagedata::ArrayGrid< T >::GetHeight(), stira::imagedata::ArrayGrid< T >::GetValue(), stira::imagedata::ArrayGrid< T >::GetWidth(), stira::imagedata::ArrayGrid< T >::MultiplyWith(), and stira::imagedata::ArrayGrid< T >::SetValue().

void stira::imagetools::ImageIO::SetOpenCvColorValue ( IplImage *  pIplImage,
int  x,
int  y,
int  bandNr,
double  value 
)
static

sets an intensity at position (x,y) in an OpenCV image in the specified color band

Parameters
pIplImageOpenCV image to write to
xx coordinate to write to
yy coordinate to write to
bandNrnumber of the color band to write the value to

References stira::imagedata::ArrayGrid< T >::GetHeight(), stira::imagedata::ArrayGrid< T >::GetValue(), stira::imagedata::ArrayGrid< T >::GetWidth(), and stira::imagedata::ArrayGrid< T >::SetValue().

void stira::imagetools::ImageIO::SetOpenCvGrayValue ( IplImage *  pIplImage,
int  x,
int  y,
double  value 
)
static

sets the intensity at position (x,y) in an OpenCV image assuming it is a gray value

Parameters
pIplImageOpenCV image to write to
xx coordinate to write to
yy coordinate to write to
valuevalue to set
bool stira::imagetools::ImageIO::Write ( Image pImage,
std::string  fname,
outputType  outtype = NULL_OUT 
)
static

determines whether image object has 1 or three bands and then writes image with appropriate method to file

Parameters
pImageimage object to be written to file
fileNamename of the file to write to
outtypetype of rescaling to apply before writing to disk

References stira::imagedata::Image::GetNumberOfBands().

Referenced by stira::degradationestimation::CompareSmoothSharpDijk::Run(), and stira::contrastenhance::HazeRemover::Run().

bool stira::imagetools::ImageIO::WriteOpenCV ( Image pImage,
std::string  fname,
outputType  outtype = NORMAL_OUT 
)
static

writes an image object to a disk file

Parameters
fnamethe name of the file to write to
outtypetype of rescaling to apply before writing to disk
Returns
true if written successfully; false otherwise

References stira::imagedata::Image::Clone(), stira::imagedata::Image::GetBands(), stira::imagedata::Image::GetHeight(), stira::imagedata::Image::GetNumberOfBands(), and stira::imagedata::Image::GetWidth().

Referenced by stira::filter::LocalBinaryPattern::ComputeJensenShannonDivergenceBetweenImagePatches(), and stira::filter::LocalBinaryPattern::ComputePointLBPSymHistogram().

bool stira::imagetools::ImageIO::WriteOpenCV ( ArrayGrid< double > *  pGrid,
std::string  fname,
outputType  outtype = NORMAL_OUT 
)
static

writes a single grid object of double precision float values to a disk file

Parameters
fnamethe name of the file to write to
outtypetype of rescaling to apply before writing to disk
Returns
true if written successfully; false otherwise

References stira::imagedata::ArrayGrid< T >::Clone(), stira::imagedata::ArrayGrid< T >::GetHeight(), stira::imagedata::ArrayGrid< T >::GetValue(), and stira::imagedata::ArrayGrid< T >::GetWidth().

bool stira::imagetools::ImageIO::WriteOpenCV ( ArrayGrid< int > *  pGrid,
std::string  fname,
outputType  outtype = NORMAL_OUT 
)
static

writes a single grid object of integer values to a disk file

Parameters
fnamethe name of the file to write to
outtypetype of rescaling to apply before writing to disk
Returns
true if written successfully; false otherwise

References stira::imagedata::ArrayGrid< T >::GetHeight(), stira::imagedata::ArrayGrid< T >::GetValue(), and stira::imagedata::ArrayGrid< T >::GetWidth().

bool stira::imagetools::ImageIO::WriteOpenCV ( ArrayGrid< bool > *  pGrid,
std::string  fname 
)
static

writes a single grid object of booleans to a disk file

Parameters
fnamethe name of the file to write to
Returns
true if written successfully; false otherwise

References stira::imagedata::ArrayGrid< T >::GetHeight(), stira::imagedata::ArrayGrid< T >::GetValue(), and stira::imagedata::ArrayGrid< T >::GetWidth().

void stira::imagetools::ImageIO::WritePGM ( ArrayGrid< std::complex< double > > *  pGrid,
std::string  fileName,
outputType  outtype = NULL_OUT 
)
static
bool stira::imagetools::ImageIO::WritePGM ( ArrayGrid< double > *  pGrid,
std::string  fileName,
outputType  outtype = NULL_OUT 
)
static

writes an ArrayGrid of doubles from memory to disk .

Parameters
pGridArrayGrid object to be written to file
fileNamename of the file to write to
outtypetype of rescaling to apply before writing to disk

References stira::imagedata::ArrayGrid< T >::Clone(), stira::imagedata::ArrayGrid< T >::GetHeight(), stira::imagedata::ArrayGrid< T >::GetValue(), and stira::imagedata::ArrayGrid< T >::GetWidth().

bool stira::imagetools::ImageIO::WritePGM ( ArrayGrid< int > *  pGrid,
std::string  fileName,
outputType  outtype = NULL_OUT 
)
static

writes an ArrayGrid of integers from memory to disk .

Parameters
pGridArrayGrid object to be written to file
fileNamename of the file to write to
outtypetype of rescaling to apply before writing to disk

References stira::imagedata::ArrayGrid< T >::GetHeight(), stira::imagedata::ArrayGrid< T >::GetValue(), stira::imagedata::ArrayGrid< T >::GetWidth(), and stira::imagedata::ArrayGrid< T >::SetValue().

bool stira::imagetools::ImageIO::WritePGM ( ArrayGrid< bool > *  pGrid,
std::string  fileName 
)
static

writes an ArrayGrid of booleans from memory to disk .

Parameters
pGridArrayGrid object to be written to file
fileNamename of the file to write to disk

References stira::imagedata::ArrayGrid< T >::GetHeight(), stira::imagedata::ArrayGrid< T >::GetValue(), and stira::imagedata::ArrayGrid< T >::GetWidth().

bool stira::imagetools::ImageIO::WriteTXT ( ArrayGrid< double > *  pGrid,
std::string  fileName 
)
static

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