Skip to content

imgproc: parallelize column loop in weightedMedianFilter filterCore - #4245

Open
pratham-mcw wants to merge 1 commit into
opencv:4.xfrom
pratham-mcw:weightedMedian_opt
Open

pratham-mcw wants to merge 1 commit into
opencv:4.xfrom
pratham-mcw:weightedMedian_opt

Conversation

@pratham-mcw

Copy link
Copy Markdown
Contributor

Summary

  • In cv::ximgproc::weightedMedianFilter(), filterCore() processes the image one column at a time.
  • in a single thread, each column clears and rebuilds its own joint-histogram and BCB, so no state is carried from one column to the next.

Changes

  • Moved the column loop into parallel_for_ so different columns can run on different threads.
  • Each worker allocates its own joint-histogram (H), BCB and necklace-link buffers (Hf, Hb, BCBf, BCBb), so threads share no writable state. Each column writes only its own pixels of outImg.
  • For images narrower than 256 columns, nstripes is set to 1 so the loop runs as a single stripe and avoids parallel_for_ overhead on small inputs.
  • The per-column algorithm is unchanged, so the output is exactly the same as before.

Performance Benchmarks

image

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.

1 participant