Rate This Document
Findability
Accuracy
Completeness
Readability

laplacian

Usage

Calculates the second-order differential of an image.

Interface

1
void kcv_laplacian_acc(const double *_src, size_t rows, size_t cols, double *_dst);

Parameters

Parameter

Description

Value Range

Input/Output

src

Input image.

Not null. The size of the allocated memory is rows*cols*sizeof(double).

Input

rows

Number of rows of the input image.

(1,16384]

Input

cols

Number of columns of the input image.

(1, 16384]

Input

dst

Output image.

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

Output

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

The value of rows or cols is less than or equal to 1.

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
#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 src_rows = 5; // Adjustable
    const size_t src_cols = 5; // Adjustable
    const size_t dst_rows = 2; // Adjustable
    const size_t dst_cols = 2; // Adjustable
    int length = src_rows * src_cols;
    double *src = (double *)malloc(length * sizeof(double));
    double *dst = (double *)malloc(length * sizeof(double));
    // 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 < src_rows; i++) {
        for (size_t j = 0; j < src_cols; j++) {
            src[i * src_cols + j] = src_data[i][j];
        }
    }
    // Call the function.
    cv::kcv_laplacian_acc(src, src_rows, src_cols, dst);
    // Print the result (only part of the result is printed here).
    printf("Upsampled Image:\n");
    for (size_t i = 0; i < dst_rows; i++) {
        for (size_t j = 0; j < dst_cols; j++) {
            printf("%.2f ", dst[i * dst_cols + j]);
            if (j == dst_cols - 1) {
                printf("\n");
            }
        }
    }
}
int main() {
    test_kcv_laplacian_acc();
    return 0;
}

Output:

1
2
3
Upsampled Image:
0.00 0.00 
0.00 0.00