Max
Computes the maximum pixel value in a specified region of the source image. In the case of multi-channel images, the maximum value is calculated on each channel and stored in the max array.
The function interface declaration is as follows:
- Selecting the maximum pixel value on single channel data:
HmppResult HMPPI_Max_8u_C1R(const uint8_t *src, int32_t srcStep, HmppiSize roiSize, uint8_t *max);
HmppResult HMPPI_Max_16u_C1R(const uint16_t *src, int32_t srcStep, HmppiSize roiSize, uint16_t *max);
HmppResult HMPPI_Max_16s_C1R(const int16_t *src, int32_t srcStep, HmppiSize roiSize, int16_t *max);
HmppResult HMPPI_Max_32f_C1R(const float *src, int32_t srcStep, HmppiSize roiSize, float *max);
- Selecting the maximum pixel value on multi channel data:
HmppResult HMPPI_Max_8u_C3R(const uint8_t *src, int32_t srcStep, HmppiSize roiSize, uint8_t max[3]);
HmppResult HMPPI_Max_16u_C3R(const uint16_t *src, int32_t srcStep, HmppiSize roiSize, uint16_t max[3]);
HmppResult HMPPI_Max_16s_C3R(const int16_t *src, int32_t srcStep, HmppiSize roiSize, int16_t max[3]);
HmppResult HMPPI_Max_32f_C3R(const float *src, int32_t srcStep, HmppiSize roiSize, float max[3]);
HmppResult HMPPI_Max_8u_AC4R(const uint8_t *src, int32_t srcStep, HmppiSize roiSize, uint8_t max[3]);
HmppResult HMPPI_Max_16u_AC4R(const uint16_t *src, int32_t srcStep, HmppiSize roiSize, uint16_t max[3]);
HmppResult HMPPI_Max_16s_AC4R(const int16_t *src, int32_t srcStep, HmppiSize roiSize, int16_t max[3]);
HmppResult HMPPI_Max_32f_AC4R(const float *src, int32_t srcStep, HmppiSize roiSize, float max[3]);
HmppResult HMPPI_Max_8u_C4R(const uint8_t *src, int32_t srcStep, HmppiSize roiSize, uint8_t max[4]);
HmppResult HMPPI_Max_16u_C4R(const uint16_t *src, int32_t srcStep, HmppiSize roiSize, uint16_t max[4]);
HmppResult HMPPI_Max_16s_C4R(const int16_t *src, int32_t srcStep, HmppiSize roiSize, int16_t max[4]);
HmppResult HMPPI_Max_32f_C4R(const float *src, int32_t srcStep, HmppiSize roiSize, float max[4]);
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
src |
Pointer to the source image ROI |
The value cannot be NULL. |
Input |
srcStep |
Distance between starts of consecutive lines in the source 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 |
max |
Pointer to the maximum pixel value (for single-channel data) |
The value cannot be NULL. |
Input/Output |
max[] |
Pointer to the array storing maximum pixel values (for multi-channel data) |
The value cannot be NULL. |
Input/Output |
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_ROI_ERR |
roiSize.width > Step |
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
void MaxExample()
{
HmppiSize roi = {6, 6};
const float src[8*8] = {124.5, 913, 13453434, 57.5, 23.75, 63.375, 98.0625, 2343,
57.540001, 16.845346, 256.14001, 98.709999, 736.23999, 459.64999, 80.102997, 90.989998,
4013, 4238, 11940, 32200, 15709, 38807, 4239, 11942,
95345008, 25438044, 8.5345428e+09, 1.0534482e+08, 0.2, 0.23, 0.36000001, 0.56999999,
0.25001001, 0.87011999, 0.99010998, 0.54004002, 0.25999999, 0.33000001, 0.63, 0.75,
0.75001001, 0.90012002, 53450.691, 0.34004, 16411.25, 12293.375, 12779.5, 15498.062,
16411.211, 12293.377, 12779.52, 15498.062, 65519, 65520, 65519, 65520,
65504, 65504, 0.00013, 0.00013, 0, 1, 1, 3.4028235e+38};
float vMax;
int32_t srcStep = 8 * sizeof(float);
HmppResult result = HMPPI_Max_32f_C1R(src, srcStep, roi, &vMax);
printf("result = %d \n vMax = ", result);
if (result != HMPP_STS_NO_ERR) {
printf("result error: %d\n", result);
}
printf("%f\n", vMax);
return 0;
}
int main(void)
{
MaxExample();
return 0;
}
Output:
result = 0 vMax = 8.5345428e+09