MCPcopy Create free account
hub / github.com/RenderKit/embree / compareImages

Function compareImages

tutorials/common/image/image.cpp:13–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11namespace embree
12{
13 double compareImages(Ref<Image> image0, Ref<Image> image1)
14 {
15 /* compare image size */
16 const size_t width = image0->width;
17 const size_t height = image0->height;
18 if (image1->width != width) return inf;
19 if (image1->height != height) return inf;
20
21 /* compare both images */
22 double diff = 0.0;
23 for (size_t y=0; y<height; y++)
24 {
25 for (size_t x=0; x<width; x++)
26 {
27 const Color c0 = image0->get(x,y);
28 const Color c1 = image1->get(x,y);
29 diff += sqr(fabs(c0.r - c1.r))/3.0f;
30 diff += sqr(fabs(c0.g - c1.g))/3.0f;
31 diff += sqr(fabs(c0.b - c1.b))/3.0f;
32 }
33 }
34
35 return diff;
36 }
37
38 /*! loads an image from a file with auto-detection of format */
39 Ref<Image> loadImageFromDisk(const FileName& fileName)

Callers 1

Calls 2

sqrFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected