#include <Filter.h>
Classes | |
struct | Coefficients |
Public Types | |
enum | { Impulse , Cubic , Keys , Simon , Rifman , Mitchell , Parzen , Notch , Lanczos4 , Lanczos6 , Sinc4 , NumFilters } |
Public Member Functions | |
int | type () const |
void | type (int t) |
Knob * | filterKnob () |
Filter (int type=Cubic) | |
void | initialize () |
bool | get (float position, float width, Coefficients &) const |
bool | impulse () const |
bool | interpolative () const |
void | knobs (Knob_Callback, const char *name="filter", const char *label=nullptr) |
Static Public Attributes | |
static const char * | NAMES [] |
Name text array for menus. | |
static const char * | HELP |
Help text for tooltips. | |
Protected Attributes | |
int | type_ |
Enumeration in built-in list. | |
float * | filter_array |
Filter data in an XY array. | |
Knob * | filter_knob_ |
Generates and returns 1-dimensional filter arrays. These are designed to be multiplied by source pixels to calculate an output pixel for a transformation or texture mapping operation.
This object is actually just a small holder of an enumeration describing the type of filter. The filter coefficients are actually in static memory and shared between all instances of the same filter type.
You can declare a static one of these if you want a filter. To allow the user to choose the type of filter, put one of these into your Op and then call the knobs() method inside your own Op::knobs() method to allow the user to change the type.
Filter::Filter | ( | int | type = Cubic | ) |
The integer t indicates what type of filter is wanted. It is a number designed to be stored in an Enumeration_knob, you should use the Filter::NAMES to get the names of all the defined filters.
void Filter::initialize | ( | ) |
This must be called before get() can be called. It fills in the static source for the filter arrays. If anybody has called this for the same type before, this will return immediately.
References filter_array, and type_.
bool Filter::get | ( | float | position, |
float | width, | ||
Filter::Coefficients & | result | ||
) | const |
Return a filter float array.
position is the coordinate the filter is centered on.
width is the derivative of the transform. This must be positive so take the absolute value before calling this.
result is set to the desired values. The actual coefficients are in static memory and the result.array will point at them. See Filter::Coefficients::apply() for how to use this.
The return value is true if the filter is equivalent to a 1.0-wide one. This is very common and you can use this to apply the filter faster by special-casing the code. In this case:
References DD::Image::Filter::Coefficients::array, DD::Image::Filter::Coefficients::count, DD::Image::Filter::Coefficients::delta, fast_rint(), filter_array, DD::Image::Filter::Coefficients::first, DD::Image::Filter::Coefficients::normalize, and type_.
Referenced by DD::Image::Iop::do_sample_shadowmap(), DD::Image::Iop::doSample(), and DD::Image::Transform::sample().
bool Filter::interpolative | ( | ) | const |
Returns true if the 1-wide centered filter has a value of zero at +1 and -1. This indicates that the image does not change if there is only integer translation.
References type_.
Referenced by DD::Image::Transform::_validate().
void Filter::knobs | ( | Knob_Callback | f, |
const char * | name = "filter" , |
||
const char * | label = nullptr |
||
) |
Filter-selection control.
References DD::Image::Enumeration_knob(), HELP, NAMES, DD::Image::Tooltip(), and type_.
Referenced by DD::Image::Transform::filter_knobs().
©2024 The Foundry Visionmongers, Ltd. All Rights Reserved. |