Resize
Adjusts the size of a three-dimensional image.
The function interface is declared as follows:
- 3D image resizing:
HmppResult HMPPI_RResize_8u_C1V(const uint8_t *pSrc, HmpprVolume srcVolume, int srcStep, int srcPlaneStep,
HmpprCuboid srcVoi, uint8_t *pDst, int dstStep, int dstPlaneStep, HmpprCuboid dstVoi, double xFactor,
double yFactor, double zFactor, double xShift, double yShift, double zShift, int interpolation);
HmppResult HMPPI_RResize_16u_C1V(const uint16_t *pSrc, HmpprVolume srcVolume, int srcStep, int srcPlaneStep,
HmpprCuboid srcVoi, uint16_t *pDst, int dstStep, int dstPlaneStep, HmpprCuboid dstVoi, double xFactor,
double yFactor, double zFactor, double xShift, double yShift, double zShift, int interpolation);
HmppResult HMPPI_RResize_32f_C1V(const float *pSrc, HmpprVolume srcVolume, int srcStep, int srcPlaneStep,
HmpprCuboid srcVoi, float *pDst, int dstStep, int dstPlaneStep, HmpprCuboid dstVoi, double xFactor,
double yFactor, double zFactor, double xShift, double yShift, double zShift, int interpolation);
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
pSrc |
Pointer to the origin of the source volume |
The value cannot be NULL. |
Input |
srcVolume |
Size of the source volume |
Positive integer |
Input |
srcStep |
Distance between starts of consecutive lines within each plane of the source volume, in bytes |
The value must be zero or a positive integer. |
Input |
srcPlaneStep |
Distance between consecutive planes of the source volume, in bytes |
The value must be zero or a positive integer. |
Input |
srcVoi |
Volume of interest (VOI) within the source volume |
Positive integer |
Input |
pDst |
Pointer to the origin of the destination volume |
The value cannot be NULL. |
Input/Output |
dstStep |
Distance between starts of consecutive lines within each plane of the destination volume, in bytes |
The value must be zero or a positive integer. |
Input |
dstPlaneStep |
Distance between consecutive planes of the destination volume, in bytes |
The value must be zero or a positive integer. |
Input |
dstVoi |
VOI within the destination volume |
Positive integer |
Input |
xFactor |
Factor for changing the X dimension of the source VOI |
Positive number |
Input |
yFactor |
Factor for changing the Y dimension of the source VOI |
Positive number |
Input |
zFactor |
Factor for changing the Z dimension of the source VOI |
Positive number |
Input |
xShift |
Offset in the X direction |
Real number |
Input |
yShift |
Offset in the Y direction |
Real number |
Input |
zShift |
Offset in the Z direction |
Real number |
Input |
interpolation |
Interpolation algorithm |
The following algorithm is supported: HMPPI_INTER_NN |
Input |
Return Value
- Success: HMPP_STS_NO_ERR
- Failure: An error code is returned.
Error Codes
Error Code |
Description |
|---|---|
HMPP_STS_NULL_PTR_ERR |
A null pointer exists. |
HMPP_STS_STEP_ERR |
The value of srcStep, srcPlaneStep, dstStep, or dstPlaneStep is negative. Or: For example, srcStep is less than srcVolume.width x Byte length of the input data type, srcPlaneStep is less than srcStep x srcVolume.height, etc. |
HMPP_STS_SIZE_ERR |
The width, height, or depth of srcVolume, srcVoi, or dstVoi is negative. |
HMPP_STS_INTERPOLAION_ERR |
The interpolation algorithm is not supported. |
HMPP_STS_WRONG_INTERSECT_VOI |
The value of x/y/z of srcVoi is greater than the width/height/depth of srcVolume. |
HMPP_STS_RESIZE_FACTOR_ERR |
The value of xFactor, yFactor, or zFactor is negative or 0. |
Example
void ResizeExample()
{
HmpprVolume srcVolume = {2, 2, 2};
HmpprCuboid srcVoi = {0, 0, 0, 2, 2, 2};
HmpprCuboid dstVoi = {0, 0, 0, 3, 3, 3};
int srcStep = 2 * sizeof(uint16_t);
int dstStep = 3 * sizeof(uint16_t);
int srcPlaneStep = srcStep * 2;
int dstPlaneStep = dstStep * 3;
double xFactor = 1.5;
double yFactor = 1.5;
double zFactor = 1.5;
double xShift = 0.;
double yShift = 0.;
double zShift = 0.;
uint16_t pSrc[] = {1, 2, 3, 4, 5, 6, 7, 8};
int dstLen = dstVoi.width * dstVoi.height * dstVoi.depth;
uint16_t *pDst = HMPPS_Malloc_16u(dstLen);
HmppResult result = HMPPI_RResize_16u_C1V(pSrc, srcVolume, srcStep, srcPlaneStep, srcVoi, pDst, dstStep, dstPlaneStep,
dstVoi, xFactor, yFactor, zFactor, xShift, yShift, zShift, HMPPI_INTER_NN);
printf("result = %d\n", result);
if (result != HMPP_STS_NO_ERR) {
return;
}
for (int i = 0; i < dstLen; i++){
printf("%d ", pDst[i]);
}
printf("\n");
}
Output:
result = 0 1 2 2 3 4 4 3 4 4 5 6 6 7 8 8 7 8 8 5 6 6 7 8 8 7 8 8