The Convolve test group has 1,009 tests - the largest single test group in the entire CTS suite (6.6% of all tests).
vxConvolve allows custom convolution kernels (not just the fixed 3x3 filters like Gaussian/Box).
Key requirements:
- Variable kernel sizes (up to 9x9 or larger)
- Custom kernel coefficients (i16 values)
- Kernel scaling factor
- Multiple border handling modes
VxCConvolution (in c_api_data.rs):
pub struct VxCConvolution {
pub rows: usize,
pub cols: usize,
pub scale: u32,
pub data: RwLock<Vec<i16>>, // Kernel coefficients
}vxCreateConvolution - Create convolution object:
pub extern "C" fn vxCreateConvolution(
context: vx_context,
columns: vx_size,
rows: vx_size,
) -> vx_convolutionvxQueryConvolution - Query attributes:
VX_CONVOLUTION_ROWS
VX_CONVOLUTION_COLUMNS
VX_CONVOLUTION_SCALE
VX_CONVOLUTION_SIZEvxSetConvolutionAttribute - Set scale:
VX_CONVOLUTION_SCALEvxCopyConvolutionCoefficients - Get/Set coefficients:
// Read/write i16 coefficientsGeneric convolution for any kernel size:
pub fn convolve(src: &Image, dst: &Image, kernel: &VxCConvolution) -> VxResult<()> {
let k_rows = kernel.rows;
let k_cols = kernel.cols;
let k_center_x = k_cols / 2;
let k_center_y = k_rows / 2;
let scale = kernel.scale as i32;
for y in 0..src.height() {
for x in 0..src.width() {
let mut sum: i32 = 0;
// Apply kernel
for ky in 0..k_rows {
for kx in 0..k_cols {
let src_x = x as isize + kx as isize - k_center_x as isize;
let src_y = y as isize + ky as isize - k_center_y as isize;
let pixel = get_pixel_bordered(src, src_x, src_y, border) as i32;
let coeff = kernel.data[ky * k_cols + kx] as i32;
sum += pixel * coeff;
}
}
// Apply scale and clamp
if scale > 0 {
sum = sum / scale;
}
dst.set_pixel(x, y, sum.max(0).min(255) as u8);
}
}
Ok(())
}ConvolveKernel in openvx-vision/src/filter.rs or geometric.rs:
pub struct ConvolveKernel;
impl KernelTrait for ConvolveKernel {
fn get_name(&self) -> &str { "org.khronos.openvx.custom_convolution" }
fn get_enum(&self) -> VxKernel { VxKernel::Convolve }
fn validate(&self, params: &[&dyn Referenceable]) -> VxResult<()> {
// Need: input image, convolution object, output image
if params.len() < 3 {
return Err(VxStatus::ErrorInvalidParameters);
}
Ok(())
}
fn execute(&self, params: &[&dyn Referenceable], _context: &Context) -> VxResult<()> {
let src = params[0].as_any().downcast_ref::<Image>().ok_or(...)?;
let conv = params[1].as_any().downcast_ref::<VxCConvolution>().ok_or(...)?;
let dst = params[2].as_any().downcast_ref::<Image>().ok_or(...)?;
convolve(src, dst, conv)?;
Ok(())
}
}Agent: convolve-analysis-agent Task: Check if vxCreateConvolution and related functions exist Files: openvx-core/src/c_api_data.rs, openvx-vision/src/filter.rs
Agent: convolve-data-agent Task: Ensure VxCConvolution struct and all API functions work Files: openvx-core/src/c_api_data.rs
Agent: convolve-algorithm-agent
Task: Implement generic convolution with any kernel size
Files: openvx-vision/src/filter.rs or new file
Agent: convolve-kernel-agent Task: Implement ConvolveKernel::execute() Files: openvx-vision/src/filter.rs
Agent: convolve-test-agent Task: Run Convolve* tests and verify fixes Expected: 900+ tests passing
- Stored as
Vec<i16>(signed 16-bit) - Row-major order: data[row * cols + col]
- Center of kernel at (cols/2, rows/2)
- VX_BORDER_UNDEFINED: Skip border pixels (output = 0)
- VX_BORDER_CONSTANT: Use constant value (0)
- VX_BORDER_REPLICATE: Repeat edge pixels
- Used to prevent overflow: result = sum / scale
- Default scale = 1 (no scaling)
- User can set via vxSetConvolutionAttribute
- vxCreateConvolution: Creates convolution object
- vxQueryConvolution: Returns correct attributes
- vxCopyConvolutionCoefficients: Read/write coefficients
- ConvolveKernel::execute: Performs convolution
- Convolve tests*: 900+ tests passing
1,009 tests - This single fix could add 6.6% to overall conformance!
-
openvx-core/src/c_api_data.rs
- VxCConvolution struct (if not exists)
- vxCreateConvolution
- vxQueryConvolution
- vxSetConvolutionAttribute
- vxCopyConvolutionCoefficients
- vxReleaseConvolution
-
openvx-vision/src/filter.rs (or new file)
- convolve() function
- ConvolveKernel implementation
-
openvx-vision/src/lib.rs
- Register ConvolveKernel