| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef SKIA_EXT_RECURSIVE_GAUSSIAN_CONVOLUTION_H_ | |
| 6 #define SKIA_EXT_RECURSIVE_GAUSSIAN_CONVOLUTION_H_ | |
| 7 | |
| 8 #include "skia/ext/convolver.h" | |
| 9 #include "third_party/skia/include/core/SkSize.h" | |
| 10 #include "third_party/skia/include/core/SkTypes.h" | |
| 11 | |
| 12 namespace skia { | |
| 13 | |
| 14 // RecursiveFilter, paired with SingleChannelRecursiveGaussianX and | |
| 15 // SingleChannelRecursiveGaussianY routines below implement recursive filters as | |
| 16 // described in 'Recursive implementation of the Gaussian filter' (Young, Vliet) | |
| 17 // (1995). Single-letter variable names mirror exactly the usage in the paper to | |
| 18 // ease reading and analysis. | |
| 19 class RecursiveFilter { | |
| 20 public: | |
| 21 enum Order { | |
| 22 FUNCTION, | |
| 23 FIRST_DERIVATIVE, | |
| 24 SECOND_DERIVATIVE | |
| 25 }; | |
| 26 | |
| 27 static float qFromSigma(float sigma); | |
| 28 static void computeCoefficients(float q, float b[4]); | |
| 29 SK_API RecursiveFilter(float sigma, Order order); | |
| 30 | |
| 31 Order order() const { return order_; } | |
| 32 const float* b() const { return b_; } | |
| 33 | |
| 34 private: | |
| 35 Order order_; | |
| 36 float q_; | |
| 37 float b_[4]; | |
| 38 }; | |
| 39 | |
| 40 // Applies a gaussian recursive filter given as |filter| to a single channel at | |
| 41 // |input_channel_index| to image given in |source_data| along X axis. | |
| 42 // The output is placed into |output| into channel |output_channel_index|. | |
| 43 SK_API unsigned char SingleChannelRecursiveGaussianX( | |
| 44 const unsigned char* source_data, | |
| 45 int source_byte_row_stride, | |
| 46 int input_channel_index, | |
| 47 int input_channel_count, | |
| 48 const RecursiveFilter& filter, | |
| 49 const SkISize& image_size, | |
| 50 unsigned char* output, | |
| 51 int output_byte_row_stride, | |
| 52 int output_channel_index, | |
| 53 int output_channel_count, | |
| 54 bool absolute_values); | |
| 55 | |
| 56 // Applies a gaussian recursive filter along Y axis. | |
| 57 SK_API unsigned char SingleChannelRecursiveGaussianY( | |
| 58 const unsigned char* source_data, | |
| 59 int source_byte_row_stride, | |
| 60 int input_channel_index, | |
| 61 int input_channel_count, | |
| 62 const RecursiveFilter& filter, | |
| 63 const SkISize& image_size, | |
| 64 unsigned char* output, | |
| 65 int output_byte_row_stride, | |
| 66 int output_channel_index, | |
| 67 int output_channel_count, | |
| 68 bool absolute_values); | |
| 69 } // namespace skia | |
| 70 | |
| 71 #endif // SKIA_EXT_RECURSIVE_GAUSSIAN_CONVOLUTION_H_ | |
| OLD | NEW |