OLD | NEW |
1 #include <cmath> | 1 #include <cmath> |
| 2 #include <math.h> |
2 | 3 |
3 #include "SkBitmap.h" | 4 #include "SkBitmap.h" |
4 #include "skpdiff_util.h" | 5 #include "skpdiff_util.h" |
5 #include "SkPMetric.h" | 6 #include "SkPMetric.h" |
6 #include "SkPMetricUtil_generated.h" | 7 #include "SkPMetricUtil_generated.h" |
7 | 8 |
8 struct RGB { | 9 struct RGB { |
9 float r, g, b; | 10 float r, g, b; |
10 }; | 11 }; |
11 | 12 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 } | 153 } |
153 } | 154 } |
154 bitmap->unlockPixels(); | 155 bitmap->unlockPixels(); |
155 return true; | 156 return true; |
156 } | 157 } |
157 | 158 |
158 // From Barten SPIE 1989 | 159 // From Barten SPIE 1989 |
159 static float contrast_sensitivity(float cyclesPerDegree, float luminance) { | 160 static float contrast_sensitivity(float cyclesPerDegree, float luminance) { |
160 float a = 440.0f * powf(1.0f + 0.7f / luminance, -0.2f); | 161 float a = 440.0f * powf(1.0f + 0.7f / luminance, -0.2f); |
161 float b = 0.3f * powf(1.0f + 100.0f / luminance, 0.15f); | 162 float b = 0.3f * powf(1.0f + 100.0f / luminance, 0.15f); |
162 return a * | 163 float exp = expf(-b * cyclesPerDegree); |
163 cyclesPerDegree * | 164 float root = sqrtf(1.0f + 0.06f * expf(b * cyclesPerDegree)); |
164 expf(-b * cyclesPerDegree) * | 165 if (!std::isfinite(exp) || !std::isfinite(root)) { |
165 sqrtf(1.0f + 0.06f * expf(b * cyclesPerDegree)); | 166 return 0; |
| 167 } |
| 168 return a * cyclesPerDegree * exp * root; |
166 } | 169 } |
167 | 170 |
168 #if 0 | 171 #if 0 |
169 // We're keeping these around for reference and in case the lookup tables are no
longer desired. | 172 // We're keeping these around for reference and in case the lookup tables are no
longer desired. |
170 // They are no longer called by any code in this file. | 173 // They are no longer called by any code in this file. |
171 | 174 |
172 // From Daly 1993 | 175 // From Daly 1993 |
173 static float visual_mask(float contrast) { | 176 static float visual_mask(float contrast) { |
174 float x = powf(392.498f * contrast, 0.7f); | 177 float x = powf(392.498f * contrast, 0.7f); |
175 x = powf(0.0153f * x, 4.0f); | 178 x = powf(0.0153f * x, 4.0f); |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 if (!bitmap_to_cielab(baseline, &baselineLAB) || !bitmap_to_cielab(test, &te
stLAB)) { | 457 if (!bitmap_to_cielab(baseline, &baselineLAB) || !bitmap_to_cielab(test, &te
stLAB)) { |
455 return true; | 458 return true; |
456 } | 459 } |
457 | 460 |
458 result->poiCount = 0; | 461 result->poiCount = 0; |
459 result->result = pmetric(&baselineLAB, &testLAB, &result->poiCount); | 462 result->result = pmetric(&baselineLAB, &testLAB, &result->poiCount); |
460 result->timeElapsed = get_seconds() - startTime; | 463 result->timeElapsed = get_seconds() - startTime; |
461 | 464 |
462 return true; | 465 return true; |
463 } | 466 } |
OLD | NEW |