MinEvery
Calculates the minimum value for each pair of pixels at the same location in two images and stores the result in the destination image.
The function interface is declared as follows:
- Selecting the minimum pixel value on single-channel data:
HmppResult HMPPI_MinEvery_32f_C1R(const float *pSrc1, int src1Step, const float *pSrc2, int src2Step, float *pDst, int dstStep, HmppiSize roiSize);
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
pSrc1 |
Pointer to the ROI of source image 1 |
The value cannot be NULL. |
Input |
src1Step |
Distance between starts of consecutive lines in source image 1, in bytes |
The value must be zero or a positive integer. |
Input |
pSrc2 |
Pointer to the ROI of source image 2 |
The value cannot be NULL. |
Input |
src2Step |
Distance between starts of consecutive lines in source image 2, in bytes |
The value must be zero or a positive integer. |
Input |
pDst |
Pointer to the destination image |
The value cannot be NULL. |
Output |
dstStep |
Distance between starts of consecutive lines in the destination image, in bytes |
The value must be zero or a positive integer. |
Input |
roiSize |
Size of the ROI of the source and destination images, in pixels |
roiSize.width ∈ (0, INT_MAX], roiSize.height ∈ (0, INT_MAX] |
Input |
Return Value
- Success: HMPP_STS_NO_ERR
- Failure: An error code is returned.
Error Codes
Error Code |
Description |
|---|---|
HMPP_STS_NULL_PTR_ERR |
The value of src or max is NULL. |
HMPP_STS_STEP_ERR |
The value of srcStep is less than or equal to 0. |
HMPP_STS_SIZE_ERR |
The value of roiSize.width or roiSize.height is less than or equal to 0. |
HMPP_STS_NOT_EVEN_STEP_ERROR |
The value of srcStep cannot be exactly divided by the byte length of the data type to which src belongs. |
Example
#include <hmpp.h>
#include <stdio.h>
#define BUFFER_SIZE_T 10
void MinEveryExample(void)
{
float src1[BUFFER_SIZE_T] = {1.64, 1.63, -1.09, 0.71, -3.20, -0.43, 0.41, -4.83, 5.36, -4.40};
float src2[BUFFER_SIZE_T] = {9.54, 3.77, 2.1, -3.77, 1.59, 2.9, -3.77, 8.91, 0.19, -0.11};
float dst[BUFFER_SIZE_T];
(void)HMPPS_Zero_32f(dst, BUFFER_SIZE_T); // Initialize all elements of dst to 0.
HmppiSize roiSize = {2, 5};
HmppResult result = HMPPI_MinEvery_32f_C1R(src1, 2 * sizeof(float), src2, 2 * sizeof(float),
dst, 2 * sizeof(float), roiSize);
printf("result = %d\n", result);
if (result != HMPP_STS_NO_ERR) {
return;
}
printf("dst =");
for (int i = 0; i < BUFFER_SIZE_T; i++) {
printf(" %.2f", dst[i]);
}
printf("\n");
}
int main() {
MinEveryExample();
return 0;
}
Output:
result = 0 dst = 1.64 1.63 -1.09 -3.77 -3.20 -0.43 -3.77 -4.83 0.19 -4.40