Skip to content

Filter selection enhancements #2136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/doc/imagebufalgo.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1818,7 +1818,8 @@ \section{Convolutions}

Kernel names can be: \qkw{gaussian}, \qkw{sharp-gaussian}, \qkw{box},
\qkw{triangle}, \qkw{mitchell}, \qkw{blackman-harris}, \qkw{b-spline},
\qkw{catmull-rom}, \qkw{lanczos3}, \qkw{cubic}, \qkw{keys}, \qkw{simon},
\qkw{catmull-rom}, \qkw{lanczos3} (synonym: \qkw{nuke-lanczos6}),
\qkw{cubic}, \qkw{keys}, \qkw{simon},
\qkw{rifman}, \qkw{disk}, \qkw{binomial}, \qkw{laplacian}. Note that
\qkw{catmull-rom} and \qkw{lanczos3} are fixed-size kernels that don't
scale with the width, and are therefore probably less useful in most
Expand Down
5 changes: 3 additions & 2 deletions src/doc/oiiotool.tex
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ \section{\oiiotool commands: general and image information}

\apiitem{\ce --help}
Prints full usage information to the terminal, as well as information
about image formats supported, known color spaces, OIIO build options
about image formats supported, known color spaces, filters, OIIO build options
and library dependencies.
\apiend

Expand Down Expand Up @@ -1772,7 +1772,8 @@ \section{\oiiotool commands that make entirely new images}
Kernel names can be: {\cf gaussian}, {\cf sharp-gaussian}, {\cf box},
{\cf triangle}, {\cf blackman-harris}, {\cf mitchell}, {\cf b-spline},
\qkw{cubic}, \qkw{keys}, \qkw{simon}, \qkw{rifman}, {\cf disk}.
There are also {\cf catmull-rom} and {\cf lanczos3}, but
There are also {\cf catmull-rom} and {\cf lanczos3} (and its synonym,
{\cf nuke-lanczos6}), but
they are fixed-size kernels that don't scale with the width, and are
therefore probably less useful in most cases.

Expand Down
2 changes: 2 additions & 0 deletions src/include/OpenImageIO/filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class OIIO_API Filter1D {
static int num_filters();
/// Get the info for a particular index (0..num_filters()-1).
static void get_filterdesc(int filternum, FilterDesc* filterdesc);
static const FilterDesc& get_filterdesc(int filternum);

protected:
float m_w;
Expand Down Expand Up @@ -143,6 +144,7 @@ class OIIO_API Filter2D {
static int num_filters();
/// Get the info for a particular index (0..num_filters()-1).
static void get_filterdesc(int filternum, FilterDesc* filterdesc);
static const FilterDesc& get_filterdesc(int filternum);

protected:
float m_w, m_h;
Expand Down
32 changes: 25 additions & 7 deletions src/libutil/filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
// - prman 16.0 txmake
//
// box: oiio, prman, katana, imagemagick match
// lanczos3: oiio, katana, imagemagick match. prman is far sharper (perhaps lanczos2?)
// lanczos3: oiio, katana, imagemagick match. prman is far sharper
// (perhaps lanczos2?). Note that Nuke calls this filter "lanczos6" (they
// measure full width).
// sinc: oiio, prman match. Katana is slighly softer. imagemagick is much softer
// blackman harris: all differ. In order of decreasing sharpness... imagemagick, oiio, prman
// catrom: oiio, imagemagick, prman match
Expand Down Expand Up @@ -848,6 +850,7 @@ FilterDesc filter1d_list[] = {
{ "blackman-harris", 1, 3, false, true, true },
{ "sinc", 1, 4, false, true, true },
{ "lanczos3", 1, 6, false, true, true },
{ "nuke-lanczos6", 1, 6, false, true, true },
{ "mitchell", 1, 4, false, true, true },
{ "bspline", 1, 4, false, true, true },
{ "cubic", 1, 4, false, true, true },
Expand All @@ -864,11 +867,17 @@ Filter1D::num_filters()
return sizeof(filter1d_list) / sizeof(filter1d_list[0]);
}

const FilterDesc&
Filter1D::get_filterdesc(int filternum)
{
ASSERT(filternum >= 0 && filternum < num_filters());
return filter1d_list[filternum];
}

void
Filter1D::get_filterdesc(int filternum, FilterDesc* filterdesc)
{
ASSERT(filternum >= 0 && filternum < num_filters());
*filterdesc = filter1d_list[filternum];
*filterdesc = get_filterdesc(filternum);
}


Expand All @@ -894,7 +903,8 @@ Filter1D::create(string_view filtername, float width)
return new FilterBlackmanHarris1D(width);
if (filtername == "sinc")
return new FilterSinc1D(width);
if (filtername == "lanczos3" || filtername == "lanczos")
if (filtername == "lanczos3" || filtername == "lanczos"
|| filtername == "nuke-lanczos6")
return new FilterLanczos3_1D(width);
if (filtername == "mitchell")
return new FilterMitchell1D(width);
Expand Down Expand Up @@ -933,6 +943,7 @@ static FilterDesc filter2d_list[] = {
{ "sinc", 2, 4, false, true, true },
{ "lanczos3", 2, 6, false, true, true },
{ "radial-lanczos3", 2, 6, false, true, false },
{ "nuke-lanczos6", 2, 6, false, true, false },
{ "mitchell", 2, 4, false, true, true },
{ "bspline", 2, 4, false, true, true },
{ "disk", 2, 1, false, true, false },
Expand All @@ -949,11 +960,17 @@ Filter2D::num_filters()
return sizeof(filter2d_list) / sizeof(filter2d_list[0]);
}

const FilterDesc&
Filter2D::get_filterdesc(int filternum)
{
ASSERT(filternum >= 0 && filternum < num_filters());
return filter2d_list[filternum];
}

void
Filter2D::get_filterdesc(int filternum, FilterDesc* filterdesc)
{
ASSERT(filternum >= 0 && filternum < num_filters());
*filterdesc = filter2d_list[filternum];
*filterdesc = get_filterdesc(filternum);
}


Expand All @@ -980,7 +997,8 @@ Filter2D::create(string_view filtername, float width, float height)
return new FilterBlackmanHarris2D(width, height);
if (filtername == "sinc")
return new FilterSinc2D(width, height);
if (filtername == "lanczos3" || filtername == "lanczos")
if (filtername == "lanczos3" || filtername == "lanczos"
|| filtername == "nuke-lanczos6")
return new FilterLanczos3_2D(width, height);
if (filtername == "radial-lanczos3" || filtername == "radial-lanczos")
return new FilterRadialLanczos3_2D(width, height);
Expand Down
4 changes: 2 additions & 2 deletions src/libutil/filter_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ getargs(int argc, char* argv[])
ArgParse ap;
// clang-format off
ap.options(
"fmath_test\n" OIIO_INTRO_STRING "\n"
"Usage: fmath_test [options]",
"filter_test\n" OIIO_INTRO_STRING "\n"
"Usage: filter_test [options]",
// "%*", parse_files, "",
"--help", &help, "Print help message",
"-v", &verbose, "Verbose mode",
Expand Down
9 changes: 9 additions & 0 deletions src/oiiotool/oiiotool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5370,6 +5370,15 @@ print_help_end(const ArgParse& ap, std::ostream& out)
}
if (!ot.colorconfig.supportsOpenColorIO())
out << "No OpenColorIO support was enabled at build time.\n";

std::vector<string_view> filternames;
for (int i = 0, e = Filter2D::num_filters(); i < e; ++i)
filternames.emplace_back(Filter2D::get_filterdesc(i).name);
out << Strutil::wordwrap("Filters available: "
+ Strutil::join(filternames, ", "),
columns, 4)
<< "\n";

std::string libs = OIIO::get_string_attribute("library_list");
if (libs.size()) {
std::vector<string_view> libvec;
Expand Down