sample the edge with linear weights
| 255 | inline SampleImage(const Image8U3& _image) : image(_image), sampler() {} |
| 256 | // sample the edge with linear weights |
| 257 | void AddEdge(const TexCoord& p0, const TexCoord& p1) { |
| 258 | const TexCoord p01(p1 - p0); |
| 259 | const float length(norm(p01)); |
| 260 | ASSERT(length > 0.f); |
| 261 | const int nSamples(ROUND2INT(MAXF(length, 1.f) * 2.f)-1); |
| 262 | AccumColor edgeAccumColor; |
| 263 | for (int s=0; s<nSamples; ++s) { |
| 264 | const float len(static_cast<float>(s) / nSamples); |
| 265 | const TexCoord samplePos(p0 + p01 * len); |
| 266 | const Color color(image.sample<Sampler,Color>(sampler, samplePos)); |
| 267 | edgeAccumColor.Add(RGB2YCBCR(color), 1.f-len); |
| 268 | } |
| 269 | accumColor.Add(edgeAccumColor.Normalized(), length); |
| 270 | } |
| 271 | // returns accumulated color |
| 272 | Color GetColor() const { |
| 273 | return accumColor.Normalized(); |
no test coverage detected