Image Quality Assessment (IQA) 1.1.2
A fast, accurate, and reliable C library for measuring image quality.
Functions
source/ssim.c File Reference
#include "iqa.h"
#include "convolve.h"
#include "decimate.h"
#include "math_utils.h"
#include "ssim.h"
#include <stdlib.h>
#include <math.h>

Go to the source code of this file.

Functions

static IQA_INLINE double _calc_luminance (float, float, float, float)
static IQA_INLINE double _calc_contrast (double, float, float, float, float)
static IQA_INLINE double _calc_structure (float, double, float, float, float, float)
static int _ssim_map (const struct _ssim_int *, void *)
static float _ssim_reduce (int, int, void *)
float iqa_ssim (const unsigned char *ref, const unsigned char *cmp, int w, int h, int stride, int gaussian, const struct iqa_ssim_args *args)
float _iqa_ssim (float *ref, float *cmp, int w, int h, const struct _kernel *k, const struct _map_reduce *mr, const struct iqa_ssim_args *args)

Function Documentation

static IQA_INLINE double _calc_contrast ( double  sigma_comb_12,
float  sigma1_sqd,
float  sigma2_sqd,
float  C2,
float  beta 
) [static]

Definition at line 291 of file ssim.c.

static IQA_INLINE double _calc_luminance ( float  mu1,
float  mu2,
float  C1,
float  alpha 
) [static]

Definition at line 276 of file ssim.c.

static IQA_INLINE double _calc_structure ( float  sigma_12,
double  sigma_comb_12,
float  sigma1,
float  sigma2,
float  C3,
float  gamma 
) [static]

Definition at line 306 of file ssim.c.

float _iqa_ssim ( float *  ref,
float *  cmp,
int  w,
int  h,
const struct _kernel k,
const struct _map_reduce mr,
const struct iqa_ssim_args args 
)

Private method that calculates the SSIM value on a pre-processed image.

The input images must have stride==width. This method does not scale.

Note:
Image buffers are modified.

Map-reduce is used for doing the final SSIM calculation. The map function is called for every pixel, and the reduce is called at the end. The context is caller-defined and *not* modified by this method.

Parameters:
refOriginal reference image
cmpDistorted image
wWidth of the images
hHeight of the images
kThe kernel used as the window function
mrOptional map-reduce functions to use to calculate SSIM. Required if 'args' is not null. Ignored if 'args' is null.
argsOptional SSIM arguments for fine control of the algorithm. 0 for defaults. Defaults are a=b=g=1.0, L=255, K1=0.01, K2=0.03
Returns:
The mean SSIM over the entire image (MSSIM), or NAN if error.

Definition at line 142 of file ssim.c.

int _ssim_map ( const struct _ssim_int si,
void *  ctx 
) [static]

Definition at line 260 of file ssim.c.

float _ssim_reduce ( int  w,
int  h,
void *  ctx 
) [static]

Definition at line 268 of file ssim.c.

float iqa_ssim ( const unsigned char *  ref,
const unsigned char *  cmp,
int  w,
int  h,
int  stride,
int  gaussian,
const struct iqa_ssim_args args 
)

Calculates the Structural SIMilarity between 2 equal-sized 8-bit images.

See https://ece.uwaterloo.ca/~z70wang/publications/ssim.html

Note:
The images must have the same width, height, and stride.
Parameters:
refOriginal reference image
cmpDistorted image
wWidth of the images
hHeight of the images
strideThe length (in bytes) of each horizontal line in the image. This may be different from the image width.
gaussian0 = 8x8 square window, 1 = 11x11 circular-symmetric Gaussian weighting.
argsOptional SSIM arguments for fine control of the algorithm. 0 for defaults. Defaults are a=b=g=1.0, L=255, K1=0.01, K2=0.03
Returns:
The mean SSIM over the entire image (MSSIM), or INFINITY if error.

Definition at line 59 of file ssim.c.

 All Data Structures Files Functions Variables Typedefs Defines


Copyright (c) 2011 by Tom Distler