Skip to content

[Bug] BoxFilter operator swaps width/height kernel arguments #125

@Jayant-kernel

Description

@Jayant-kernel

Describe the bug
BoxFilter currently applies kernel size as (height, width) instead of (width, height).

When width and height are different, the filter effect is transposed relative to what the UI labels indicate.

To Reproduce
Steps to reproduce the behavior:

  1. Upload any image.
  2. Add filtering_boxfilter block.
  3. Set width = 3, height = 5.
  4. Run pipeline.
  5. Compare result against expected OpenCV behavior for kernel (3,5).

Code-level repro:

import cv2
import numpy as np
from app.operators.filtering.box_filter import BoxFilter

img = np.arange(8*9, dtype=np.uint8).reshape(8, 9)
out = BoxFilter({"width": 3, "height": 5, "depth": -1, "point_x": -1, "point_y": -1}).compute(img)

expected_wh = cv2.boxFilter(img, -1, (3,5), anchor=(-1,-1), normalize=True, borderType=cv2.BORDER_DEFAULT)
expected_hw = cv2.boxFilter(img, -1, (5,3), anchor=(-1,-1), normalize=True, borderType=cv2.BORDER_DEFAULT)

print(np.array_equal(out, expected_wh))  # False
print(np.array_equal(out, expected_hw))  # True

Expected behavior
width should map to kernel width and height should map to kernel height, so backend should call OpenCV with (width, height).

Environment:
OS: Windows 11 (local repro)
Python version: 3.14
OpenCV version: 4.13.0

Additional context
Likely relevant files:
imagelab-backend/app/operators/filtering/box_filter.py (currently passes (height, width))
imagelab-frontend/src/blocks/definitions/filtering.blocks.ts (labels show width then height)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions