Wavelet and Image class library  1.3.2
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
ImageComparison Class Reference

#include <ImageComparison.hh>

Collaboration diagram for ImageComparison:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ImageComparison (const Image &img1, const Image &img2)
 ~ImageComparison (void)
int rows (void) const
int cols (void) const
int size (void) const
Imagedifference (coeff magnify=1, bool reverse=false)
double cmpsnr (void)
double cmpmse (void)
lq distlq (double percent, FilterSet &flt, imgtype type)
double distlqd (double percent, FilterSet &flt, imgtype type)

Static Public Member Functions

static ImagetruncateForLq (const Image &image, double percent, FilterSet &flt, const decomp t=STANDARD)
static double calcLqDetailScore (const Image &truncated1, const Image &truncated2, int colorChannel=0)
static double calcLqAverageScore (const Image &truncated1, const Image &truncated2, int colorChannel=0)
static ImagetruncateForLq (const Image &image, int nKeptCoeffs, FilterSet &flt, const decomp t=STANDARD)
static ImageInformationimageInfoForLq (const Image &image, int nKeptCoeffs, FilterSet &flt, const decomp t=STANDARD)
static const float * getWeights (const imgtype imgType, int channel)

Protected Member Functions

int level (int pos)
double weight (int y, int x, imgtype type)
double lq_sum (imgtype type, bool reverse, bool oldLqd=false)

Protected Attributes

int m_ysize
int m_xsize
int m_xysize
Imagem_images [2]
logvalsm_lqcache
double m_lqDWeights [2][N_WEIGHTS]
int m_lqcachesize

Static Protected Attributes

static const float m_scWeights [][N_WEIGHTS]
static const float m_drWeights [][N_WEIGHTS]

Detailed Description

A class for differences between two images

Definition at line 43 of file ImageComparison.hh.


Constructor & Destructor Documentation

ImageComparison::ImageComparison ( const Image img1,
const Image img2 
)

Constructor. Creates copies of the two images. If the two images have different dimensions they will be resized to the largest common dimensions.

Parameters:
img1the first image
img2the second image

Destructor. Releases allocated memory.


Member Function Documentation

static double ImageComparison::calcLqAverageScore ( const Image truncated1,
const Image truncated2,
int  colorChannel = 0 
) [static]

Calculate an $L^q$ average score for a greyscale image / single color channel.

Parameters:
truncated1the first image already truncated (see truncateForLq)
truncated2the second image already truncated (see truncateForLq)
colorChannelthe number of the color channel to which the two images correspond, this is important as it has an effect on the weights chosen when calculating the score
Returns:
the average score
static double ImageComparison::calcLqDetailScore ( const Image truncated1,
const Image truncated2,
int  colorChannel = 0 
) [static]

Calculate an $L^q$ detail score for a greyscale image / single color channel.

Parameters:
truncated1the first image already truncated (see truncateForLq)
truncated2the second image already truncated (see truncateForLq)
colorChannelthe number of the color channel to which the two images correspond, this is important as it has an effect on the weights chosen when calculating the score
Returns:
the detail score
double ImageComparison::cmpmse ( void  )

Compare with another image producing the mean square error. Stolen from Geoff Davis' Wavelet Coder kit.

Returns:
The MSE
double ImageComparison::cmpsnr ( void  )

Compare with another image producing the PSNR. Stolen from Geoff Davis' Wavelet Coder kit.

Returns:
The PSNR
int ImageComparison::cols ( void  ) const [inline]

Return the number of columns.

Returns:
the number of columns

Definition at line 64 of file ImageComparison.hh.

References m_xsize.

Image* ImageComparison::difference ( coeff  magnify = 1,
bool  reverse = false 
)

Produce an image holding the difference between the first and the second image

Parameters:
magnifymultiply the result by a factor to increase / decrease visibility
reversereverse the subtraction (take img1 - img2)
Returns:
a new image containing the difference
lq ImageComparison::distlq ( double  percent,
FilterSet flt,
imgtype  type 
)

Calculate the distance to another image according to the $L^q$ norm. Idea and basic algorithm from Jacobs, Finkelstein, Salesin: "Fast multiresolution image querying", Proc. of SIGGRAPH, 95. Note that this method is deprecated as it does not strictly conform to the original algorithm. I propose using the static methods truncateForLq and calcLqAverageAcore, calcLqDetailScore instead.

Exceptions:
invalid_argumentimage is not square
Parameters:
percentthe relative number of Wavelet coefficients to compare
fltthe filter to use
typethe type of the images to be assumed (drawn or scanned)
Returns:
The $L^q$ norm
double ImageComparison::distlqd ( double  percent,
FilterSet flt,
imgtype  type 
)

Calculate the distance to another image according to the old $L^qd$ norm. Idea and basic algorithm from Jacobs, Finkelstein, Salesin: "Fast multiresolution image querying", Proc. of SIGGRAPH, 95.

Exceptions:
invalid_argumentimage is not square
Parameters:
percentthe relative number of Wavelet coefficients to compare
fltthe filter to use
typethe type of the images to be assumed (drawn or scanned)
Returns:
The $L^qd$ norm
static const float* ImageComparison::getWeights ( const imgtype  imgType,
int  channel 
) [static]

Return a reference to the weight table for a given type.

Parameters:
imgTypethe type (scanned or drawn)
channelthe channel (Y, U, V)
Returns:
the weight table
static ImageInformation* ImageComparison::imageInfoForLq ( const Image image,
int  nKeptCoeffs,
FilterSet flt,
const decomp  t = STANDARD 
) [static]

Calculates a feature vector for the $L^q$ and $L^qd$ metrics.

Parameters:
imagethe image
nKeptCoeffsthe absolute number of Wavelet coefficients to keep
fltthe filter to use
tthe decomposition type to use (default: Standard)
Returns:
an image information of overall average the n most significant coeffs sorted by absolute
int ImageComparison::level ( int  pos) [protected]

Helper method for distlq(). Calculates the weighing level for a position

Parameters:
posthe position (row or col)
Returns:
the level
double ImageComparison::lq_sum ( imgtype  type,
bool  reverse,
bool  oldLqd = false 
) [protected]

Helper method for distlq(). Calculate the sum of differences of the two decomposed images.

Parameters:
typethe type (drawn or scanned) to be assumed
reverseif true, subract the first from the second image
oldLqdif true, calculate the old Lqd way: add up the score for differing locations instead of subtracting the scores for identical values
int ImageComparison::rows ( void  ) const [inline]

Return the number of rows.

Returns:
the number of rows

Definition at line 60 of file ImageComparison.hh.

References m_ysize.

int ImageComparison::size ( void  ) const [inline]

Return the overall size.

Returns:
the overall size

Definition at line 68 of file ImageComparison.hh.

References m_xysize.

static Image* ImageComparison::truncateForLq ( const Image image,
double  percent,
FilterSet flt,
const decomp  t = STANDARD 
) [static]

Calculates a feature vector for the $L^q$ and $L^qd$ metrics.

Parameters:
imagethe image
percentthe relative number of Wavelet coefficients to keep
fltthe filter to use
tthe decomposition type to use (default: Standard)
Returns:
an image of overall average and truncated coeffs
static Image* ImageComparison::truncateForLq ( const Image image,
int  nKeptCoeffs,
FilterSet flt,
const decomp  t = STANDARD 
) [static]

Calculates a feature vector for the $L^q$ and $L^qd$ metrics.

Parameters:
imagethe image
nKeptCoeffsthe absolute number of Wavelet coefficients to keep
fltthe filter to use
tthe decomposition type to use (default: Standard)
Returns:
an image of overall average and truncated coeffs
double ImageComparison::weight ( int  y,
int  x,
imgtype  type 
) [protected]

Helper method for distlq(). Calculate the weight for a position (y, x).

Parameters:
ythe row
xthe col
typethe images' type to be assumed (drawn or scanned)
Returns:
the position's weight

Member Data Documentation

const float ImageComparison::m_drWeights[][N_WEIGHTS] [static, protected]

The default weight tables for drawn images.

Definition at line 233 of file ImageComparison.hh.

An array holding the two images to be compared.

Definition at line 220 of file ImageComparison.hh.

A cache needed by distlq() to avoid repeated calculation of floor (log (i) / log (2)).

Definition at line 224 of file ImageComparison.hh.

The size of the m_lqcache. Always as big as MAX (rows, cols).

Definition at line 236 of file ImageComparison.hh.

double ImageComparison::m_lqDWeights[2][N_WEIGHTS] [protected]

The six weights for scanned images, needed by distlq(), Y channel, according to Jacobs et.al.

Definition at line 228 of file ImageComparison.hh.

const float ImageComparison::m_scWeights[][N_WEIGHTS] [static, protected]

The default weight tables for scanned images.

Definition at line 231 of file ImageComparison.hh.

int ImageComparison::m_xsize [protected]

Number of cols.

Definition at line 215 of file ImageComparison.hh.

Referenced by cols().

int ImageComparison::m_xysize [protected]

Overall size.

Definition at line 217 of file ImageComparison.hh.

Referenced by size().

int ImageComparison::m_ysize [protected]

Number of rows.

Definition at line 213 of file ImageComparison.hh.

Referenced by rows().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines