Skip to content

Add linear and median filter operations - #30

Open
johnnynunez wants to merge 3 commits into
Libraries-Openly-Fused:mainfrom
johnnynunez:add-filter-ops
Open

Add linear and median filter operations#30
johnnynunez wants to merge 3 commits into
Libraries-Openly-Fused:mainfrom
johnnynunez:add-filter-ops

Conversation

@johnnynunez

@johnnynunez johnnynunez commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds NPP linear and rank filtering entry points to FastNPP:

  • FilterBoxBorder — mean (box) filter, 8u (C1/C3), 16u (C1), 32f (C1).
  • FilterBorder — general 2D convolution with a float coefficient kernel, 32f (C1/C3). Covers Gaussian, sharpen, emboss, arbitrary kernels.
  • FilterMedianBorder — per-channel window median, 8u (C1/C3), 16u (C1), 32f (C1).

Each runs as a single fused kernel with NPP_BORDER_REPLICATE semantics.

Dependency

Builds on the FKL filter functors in Libraries-Openly-Fused/FusedKernelLibrary#277 (box + convolution) and #278 (median). Merge those and update the fkl submodule first. Adds CUDA::nppif to the test link line.

Tests

tests/filtering/fastNPP_filter_test.cu cross-checks against nppiFilterBoxBorder, nppiFilterBorder, and nppiFilterMedianBorder (shared aligned pitch, NPP_BORDER_REPLICATE):

[PASS] FilterBoxBorder_8u_C1R    3x3 / 5x5     0 mismatches   (bit-exact)
[PASS] FilterBorder_32f_C1R      3x3 conv      0 mismatches   (max |d| 1.5e-5)
[PASS] FilterMedianBorder_8u_C1R 3x3 / 5x5     0 mismatches   (bit-exact)
ALL PASS

Integrates with CTest. CUDA 13.3 / GCC 11.5, sm_120.

@johnnynunez johnnynunez changed the title Add linear filter operations (FilterBoxBorder, FilterBorder convolution) Add linear and median filter operations Jun 24, 2026
@johnnynunez

Copy link
Copy Markdown
Contributor Author

Rebased onto current main, but this PR (linear + median filters (FilterBoxBorder/FilterBorder/FilterMedianBorder)) is BLOCKED: it #includes image_processing/linear_filter.h + median_filter.h, which is not yet merged into FKL main — it lives in FKL #277 + #278 (feat/linear-filter-ops, feat/median-filter).

Verified on RTX PRO 6000 / CUDA 13.3: it does not compile against any merged fkl (4642ba1, a63c000, or 7f25849) because those headers don't exist there yet.

Action: merge the corresponding FKL PR first, then bump the fkl submodule (a follow-up to #22) so these headers are available; this FastNPP PR will then build + pass. I rebased it locally but did not push the rebase to keep CI from going red on an unbuildable branch.

@morousg morousg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR does not compile nor execute. It is using features not present in the FKL

Comment thread include/fast_npp.h
#define FASTNPP_DEFINE_MEDIAN(NPPNAME, T) \
inline auto NPPNAME(const fk::Ptr2D<T>& pSrc, int nMaskWidth, int nMaskHeight, \
int nAnchorX, int nAnchorY) { \
return fk::MedianFilter<fk::ND::_2D, T, 49, fk::FilterBorder::REPLICATE>::build( \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This operations do not exist in the FKL, these are DPPs. We clearly need to work on the instantiable DPPs and allow them to share shared memory tiles

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants