Rate This Document
Findability
Accuracy
Completeness
Readability

gaussian_blur

Usage

Convolves an image through separable filtering with the specified Gaussian kernel.

  1. kernel_x and kernel_y are calculated based on the sigma values in the X and Y directions.
  2. Convolution based on the two kernel values is performed on the image.
  3. The image after convolution is output.

Interface

1
void kcv_GaussianBlur_acc(const float *_src, float *_dst, int m, int n, int h, int w, double sigma1, double sigma2); 

Parameters

Parameter

Description

Value Range

Input/Output

src

Input image.

Not null. The size of the allocated memory is src_rows*src_cols*sizeof(double).

Input

dst

Output image after filtering.

Not null. The size of the allocated memory is the same as that of src.

Output

m

Height of the input image.

(0, 16384]

Input

n

Width of the input image.

(0, 16384]

Input

h

Height of the Gaussian kernel.

(0, 1024]

Input

w

Width of the Gaussian kernel.

(0, 1024]

Input

sigma1

Gaussian sigma along the X direction.

(0, inf)

Input

sigma2

Gaussian sigma along the Y direction.

(0, inf)

Input

Return Values

  • Success: LITHO_IMG_STS_NO_ERR
  • Failure: an error code

Error Codes

Error Code

Description

LITHO_IMG_STS_NULL_PTR_ERR

The src or dst parameter has a null pointer.

LITHO_IMG_STS_SIZE_ERR

Any value of the m, n, h, and w parameters is 0.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <stdio.h>
#include <stdlib.h>
#include <complex.h>
#include <iostream>
#include <vector>
#include "kp_litho_img.h"

void test_kcv_laplacian_acc() {
    const size_t rows = 2; // Adjustable
    const size_t cols = 2; // Adjustable
    const size_t h = 3; // Adjustable
const size_t w = 3; // Adjustable
const double sigma1 = 3.0; // Adjustable
const double sigma2 = 4.0; // Adjustable

    int length = rows * cols;
    float *_src = (float *)malloc(length * sizeof(float));
    float *_dst = (float *)malloc(length * sizeof(float));
    // Initialize the input image (a simple 5x5 image is used as an example).
    double src_data[5][5] = {
        {0, 0, 0, 0, 0},
        {0, 1, 1, 1, 0},
        {0, 1, 0, 1, 0},
        {0, 1, 1, 1, 0},
        {0, 0, 0, 0, 0}
    };
    for (size_t i = 0; i < rows; i++) {
        for (size_t j = 0; j < cols; j++) {
            _src[i * cols + j] = src_data[i][j];
        }
    }
    // Call the function.
    cv::kcv_GaussianBlur_acc(_src, _dst, rows, cols, h, w, sigma1, sigma2);
    // Print the result (only part of the result is printed here).
    printf("Upsampled Image:\n");
    for (size_t i = 0; i < rows; i++) {
        for (size_t j = 0; j < cols; j++) {
            printf("%.2f ", _dst[i * cols + j]);
            if (j == cols - 1) {
                printf("\n");
            }
        }
    }
}
int main() {
    test_kcv_laplacian_acc();
    return 0;
}

Output:

1
2
3
Upsampled Image:
0.11 0.22 
0.22 0.45