mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-03-21 07:30:40 +01:00
pdiff: Delete all trailing whitespace.
This commit is contained in:
parent
d421a856d0
commit
34a6af3c55
8 changed files with 40 additions and 40 deletions
|
|
@ -18,7 +18,7 @@
|
|||
#include "RGBAImage.h"
|
||||
#include <stdio.h>
|
||||
|
||||
static const char* copyright =
|
||||
static const char* copyright =
|
||||
"PerceptualDiff version 1.0, Copyright (C) 2006 Yangli Hector Yee\n\
|
||||
PerceptualDiff comes with ABSOLUTELY NO WARRANTY;\n\
|
||||
This is free software, and you are welcome\n\
|
||||
|
|
@ -79,7 +79,7 @@ bool CompareArgs::Parse_Args(int argc, char **argv)
|
|||
return false;
|
||||
}
|
||||
ImgA = new RGBACairoImage (surface);
|
||||
} else if (i == 2) {
|
||||
} else if (i == 2) {
|
||||
surface = cairo_image_surface_create_from_png (argv[2]);
|
||||
if (cairo_surface_status (surface))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ class CompareArgs
|
|||
public:
|
||||
CompareArgs();
|
||||
~CompareArgs();
|
||||
bool Parse_Args(int argc, char **argv);
|
||||
bool Parse_Args(int argc, char **argv);
|
||||
void Print_Args();
|
||||
|
||||
|
||||
RGBAImage *ImgA; // Image A
|
||||
RGBAImage *ImgB; // Image B
|
||||
RGBAImage *ImgDiff; // Diff image
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ float *LPyramid::Copy(float *img)
|
|||
int max = Width * Height;
|
||||
float *out = new float[max];
|
||||
for (int i = 0; i < max; i++) out[i] = img[i];
|
||||
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ void LPyramid::Convolve(float *a, float *b)
|
|||
if (nx>=Width) nx=2*(Width-1)-nx;
|
||||
if (ny>=Height) ny=2*(Height-1)-ny;
|
||||
a[index] += Kernel[i+2] * Kernel[j+2] * b[ny * Width + nx];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,14 +20,14 @@
|
|||
|
||||
class LPyramid
|
||||
{
|
||||
public:
|
||||
public:
|
||||
LPyramid(float *image, int width, int height);
|
||||
virtual ~LPyramid();
|
||||
float Get_Value(int x, int y, int level);
|
||||
protected:
|
||||
float *Copy(float *img);
|
||||
void Convolve(float *a, float *b);
|
||||
|
||||
|
||||
// Succesively blurred versions of the original image
|
||||
float *Levels[MAX_PYR_LEVELS];
|
||||
|
||||
|
|
|
|||
|
|
@ -30,14 +30,14 @@
|
|||
* threshold of visibility in cd per m^2
|
||||
* TVI means Threshold vs Intensity function
|
||||
* This version comes from Ward Larson Siggraph 1997
|
||||
*/
|
||||
*/
|
||||
|
||||
float tvi(float adaptation_luminance)
|
||||
{
|
||||
// returns the threshold luminance given the adaptation luminance
|
||||
// units are candelas per meter squared
|
||||
|
||||
float log_a, r, result;
|
||||
float log_a, r, result;
|
||||
log_a = log10f(adaptation_luminance);
|
||||
|
||||
if (log_a < -3.94f) {
|
||||
|
|
@ -52,24 +52,24 @@ float tvi(float adaptation_luminance)
|
|||
r = log_a - 1.255f;
|
||||
}
|
||||
|
||||
result = powf(10.0f , r);
|
||||
result = powf(10.0f , r);
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// computes the contrast sensitivity function (Barten SPIE 1989)
|
||||
// given the cycles per degree (cpd) and luminance (lum)
|
||||
float csf(float cpd, float lum)
|
||||
{
|
||||
float a, b, result;
|
||||
|
||||
float a, b, result;
|
||||
|
||||
a = 440.0f * powf((1.0f + 0.7f / lum), -0.2f);
|
||||
b = 0.3f * powf((1.0f + 100.0f / lum), 0.15f);
|
||||
|
||||
result = a * cpd * expf(-b * cpd) * sqrtf(1.0f + 0.06f * expf(b * cpd));
|
||||
|
||||
return result;
|
||||
|
||||
result = a * cpd * expf(-b * cpd) * sqrtf(1.0f + 0.06f * expf(b * cpd));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -81,10 +81,10 @@ float mask(float contrast)
|
|||
float a, b, result;
|
||||
a = powf(392.498f * contrast, 0.7f);
|
||||
b = powf(0.0153f * a, 4.0f);
|
||||
result = powf(1.0f + b, 0.25f);
|
||||
result = powf(1.0f + b, 0.25f);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// convert Adobe RGB (1998) with reference white D65 to XYZ
|
||||
void AdobeRGBToXYZ(float r, float g, float b, float &x, float &y, float &z)
|
||||
|
|
@ -137,7 +137,7 @@ bool Yee_Compare(CompareArgs &args)
|
|||
args.ErrorStr = "Image dimensions do not match\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
unsigned int i, dim, pixels_failed;
|
||||
dim = args.ImgA->Get_Width() * args.ImgA->Get_Height();
|
||||
bool identical = true;
|
||||
|
|
@ -160,7 +160,7 @@ bool Yee_Compare(CompareArgs &args)
|
|||
args.ErrorStr = "Images are perceptually indistinguishable\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
char different[100];
|
||||
sprintf(different, "%d pixels are different\n", pixels_failed);
|
||||
|
||||
|
|
@ -220,14 +220,14 @@ int Yee_Compare_Images(RGBAImage *image_a,
|
|||
float *bZ = new float[dim];
|
||||
float *aLum = new float[dim];
|
||||
float *bLum = new float[dim];
|
||||
|
||||
|
||||
float *aA = new float[dim];
|
||||
float *bA = new float[dim];
|
||||
float *aB = new float[dim];
|
||||
float *bB = new float[dim];
|
||||
|
||||
if (verbose) printf("Converting RGB to XYZ\n");
|
||||
|
||||
|
||||
unsigned int x, y, w, h;
|
||||
w = image_a->Get_Width();
|
||||
h = image_a->Get_Height();
|
||||
|
|
@ -251,17 +251,17 @@ int Yee_Compare_Images(RGBAImage *image_a,
|
|||
bLum[i] = bY[i] * luminance;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (verbose) printf("Constructing Laplacian Pyramids\n");
|
||||
|
||||
|
||||
LPyramid *la = new LPyramid(aLum, w, h);
|
||||
LPyramid *lb = new LPyramid(bLum, w, h);
|
||||
|
||||
|
||||
float num_one_degree_pixels = (float) (2 * tan(field_of_view * 0.5 * M_PI / 180) * 180 / M_PI);
|
||||
float pixels_per_degree = w / num_one_degree_pixels;
|
||||
|
||||
|
||||
if (verbose) printf("Performing test\n");
|
||||
|
||||
|
||||
float num_pixels = 1;
|
||||
unsigned int adaptation_level = 0;
|
||||
for (i = 0; i < MAX_PYR_LEVELS; i++) {
|
||||
|
|
@ -269,15 +269,15 @@ int Yee_Compare_Images(RGBAImage *image_a,
|
|||
if (num_pixels > num_one_degree_pixels) break;
|
||||
num_pixels *= 2;
|
||||
}
|
||||
|
||||
|
||||
float cpd[MAX_PYR_LEVELS];
|
||||
cpd[0] = 0.5f * pixels_per_degree;
|
||||
for (i = 1; i < MAX_PYR_LEVELS; i++) cpd[i] = 0.5f * cpd[i - 1];
|
||||
float csf_max = csf(3.248f, 100.0f);
|
||||
|
||||
|
||||
float F_freq[MAX_PYR_LEVELS - 2];
|
||||
for (i = 0; i < MAX_PYR_LEVELS - 2; i++) F_freq[i] = csf_max / csf( cpd[i], 100.0f);
|
||||
|
||||
|
||||
unsigned int pixels_failed = 0;
|
||||
for (y = 0; y < h; y++) {
|
||||
for (x = 0; x < w; x++) {
|
||||
|
|
@ -301,7 +301,7 @@ int Yee_Compare_Images(RGBAImage *image_a,
|
|||
adapt *= 0.5f;
|
||||
if (adapt < 1e-5) adapt = 1e-5f;
|
||||
for (i = 0; i < MAX_PYR_LEVELS - 2; i++) {
|
||||
F_mask[i] = mask(contrast[i] * csf(cpd[i], adapt));
|
||||
F_mask[i] = mask(contrast[i] * csf(cpd[i], adapt));
|
||||
}
|
||||
float factor = 0;
|
||||
for (i = 0; i < MAX_PYR_LEVELS - 2; i++) {
|
||||
|
|
@ -346,7 +346,7 @@ int Yee_Compare_Images(RGBAImage *image_a,
|
|||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (aX) delete[] aX;
|
||||
if (aY) delete[] aY;
|
||||
if (aZ) delete[] aZ;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
int main(int argc, char **argv)
|
||||
{
|
||||
CompareArgs args;
|
||||
|
||||
|
||||
if (!args.Parse_Args(argc, argv)) {
|
||||
printf("%s", args.ErrorStr.c_str());
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -25,13 +25,13 @@
|
|||
RGBAImage* RGBAImage::ReadTiff(char *filename)
|
||||
{
|
||||
RGBAImage *fimg = 0;
|
||||
|
||||
|
||||
TIFF* tif = TIFFOpen(filename, "r");
|
||||
char emsg[1024];
|
||||
emsg[0] = 0;
|
||||
if (tif) {
|
||||
TIFFRGBAImage img;
|
||||
|
||||
|
||||
if (TIFFRGBAImageBegin(&img, tif, 0, emsg)) {
|
||||
size_t npixels;
|
||||
uint32* raster;
|
||||
|
|
@ -120,9 +120,9 @@ RGBAImage* RGBAImage::ReadPNG(char *filename)
|
|||
png_read_destroy(png_ptr, info_ptr, end_info);
|
||||
return fimg;
|
||||
}
|
||||
|
||||
|
||||
bool RGBAImage::WritePPM()
|
||||
{
|
||||
{
|
||||
if (Width <= 0) return false;
|
||||
if (Height <=0 ) return false;
|
||||
FILE *out = fopen(Name.c_str(), "wb");
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public:
|
|||
virtual unsigned int Get(int x, int y) const { return Data[x + y * Width]; }
|
||||
virtual unsigned int Get(int i) const { return Data[i]; }
|
||||
const std::string &Get_Name(void) const { return Name; }
|
||||
|
||||
|
||||
bool WritePPM();
|
||||
static RGBAImage* ReadTiff(char *filename);
|
||||
static RGBAImage* ReadPNG(char *filename);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue