Simd Library Documentation.

Home | Release Notes | Download | Documentation | Issues | GitHub

Functions for image resizing. More...

Enumerations

enum  SimdResizeChannelType {
  SimdResizeChannelByte ,
  SimdResizeChannelShort ,
  SimdResizeChannelFloat
}
 
enum  SimdResizeMethodType {
  SimdResizeMethodNearest ,
  SimdResizeMethodNearestPytorch ,
  SimdResizeMethodBilinear ,
  SimdResizeMethodBilinearCaffe ,
  SimdResizeMethodBilinearPytorch ,
  SimdResizeMethodBicubic ,
  SimdResizeMethodArea ,
  SimdResizeMethodAreaFast
}
 

Functions

SIMD_API void SimdReduceColor2x2 (const uint8_t *src, size_t srcWidth, size_t srcHeight, size_t srcStride, uint8_t *dst, size_t dstWidth, size_t dstHeight, size_t dstStride, size_t channelCount)
 Performs reducing and Gaussian blurring (in two time) a 8-bit channel color image with using window 2x2. More...
 
SIMD_API void SimdReduceGray2x2 (const uint8_t *src, size_t srcWidth, size_t srcHeight, size_t srcStride, uint8_t *dst, size_t dstWidth, size_t dstHeight, size_t dstStride)
 Performs reducing and Gaussian blurring (in two time) a 8-bit gray image with using window 2x2. More...
 
SIMD_API void SimdReduceGray3x3 (const uint8_t *src, size_t srcWidth, size_t srcHeight, size_t srcStride, uint8_t *dst, size_t dstWidth, size_t dstHeight, size_t dstStride, int compensation)
 Performs reducing and Gaussian blurring (in two time) a 8-bit gray image with using window 3x3. More...
 
SIMD_API void SimdReduceGray4x4 (const uint8_t *src, size_t srcWidth, size_t srcHeight, size_t srcStride, uint8_t *dst, size_t dstWidth, size_t dstHeight, size_t dstStride)
 Performs reducing and Gaussian blurring (in two time) a 8-bit gray image with using window 4x4. More...
 
SIMD_API void SimdReduceGray5x5 (const uint8_t *src, size_t srcWidth, size_t srcHeight, size_t srcStride, uint8_t *dst, size_t dstWidth, size_t dstHeight, size_t dstStride, int compensation)
 Performs reducing and Gaussian blurring (in two time) a 8-bit gray image with using window 5x5. More...
 
SIMD_API void * SimdResizerInit (size_t srcX, size_t srcY, size_t dstX, size_t dstY, size_t channels, SimdResizeChannelType type, SimdResizeMethodType method)
 Creates resize context. More...
 
SIMD_API void SimdResizerRun (const void *resizer, const uint8_t *src, size_t srcStride, uint8_t *dst, size_t dstStride)
 Performs image resizing. More...
 
SIMD_API void SimdStretchGray2x2 (const uint8_t *src, size_t srcWidth, size_t srcHeight, size_t srcStride, uint8_t *dst, size_t dstWidth, size_t dstHeight, size_t dstStride)
 Stretches input 8-bit gray image in two times. More...
 
template<template< class > class A>
SIMD_INLINE void ReduceGray2x2 (const View< A > &src, View< A > &dst)
 Performs reducing (in 2 times) and Gaussian blurring a 8-bit gray image with using window 2x2. More...
 
template<template< class > class A>
SIMD_INLINE void ReduceGray3x3 (const View< A > &src, View< A > &dst, bool compensation=true)
 Performs reducing (in 2 times) and Gaussian blurring a 8-bit gray image with using window 3x3. More...
 
template<template< class > class A>
SIMD_INLINE void ReduceGray4x4 (const View< A > &src, View< A > &dst)
 Performs reducing (in 2 times) and Gaussian blurring a 8-bit gray image with using window 4x4. More...
 
template<template< class > class A>
SIMD_INLINE void ReduceGray5x5 (const View< A > &src, View< A > &dst, bool compensation=true)
 Performs reducing (in 2 times) and Gaussian blurring a 8-bit gray image with using window 5x5. More...
 
template<template< class > class A>
SIMD_INLINE void ReduceGray (const View< A > &src, View< A > &dst, ::SimdReduceType reduceType, bool compensation=true)
 Performs reducing (in 2 times) and Gaussian blurring a 8-bit gray image. More...
 
template<template< class > class A>
SIMD_INLINE void Reduce2x2 (const View< A > &src, View< A > &dst)
 Performs reducing of image (in 2 times). More...
 
template<template< class > class A>
SIMD_INLINE void Resize (const View< A > &src, View< A > &dst, ::SimdResizeMethodType method=::SimdResizeMethodBilinear)
 Performs resizing of image. More...
 
template<template< class > class A>
SIMD_INLINE void Resize (const View< A > &src, View< A > &dst, const Point< ptrdiff_t > &size, ::SimdResizeMethodType method=::SimdResizeMethodBilinear)
 Performs resizing of image. More...
 
template<template< class > class A>
SIMD_INLINE void StretchGray2x2 (const View< A > &src, View< A > &dst)
 Stretches input 8-bit gray image in two times. More...
 

Detailed Description

Functions for image resizing.

Enumeration Type Documentation

◆ SimdResizeChannelType

Describes resized image channel types.

Enumerator
SimdResizeChannelByte 

8-bit integer channel type.

SimdResizeChannelShort 

16-bit integer channel type.

SimdResizeChannelFloat 

32-bit float channel type.

◆ SimdResizeMethodType

Describes methods used in order to resize image.

Enumerator
SimdResizeMethodNearest 

Nearest method.

SimdResizeMethodNearestPytorch 

Nearest Pytorch compatible method.

SimdResizeMethodBilinear 

Bilinear method.

SimdResizeMethodBilinearCaffe 

Bilinear Caffe compatible method. It is relevant only for SimdResizeChannelFloat (32-bit float channel type).

SimdResizeMethodBilinearPytorch 

Bilinear Pytorch compatible method. It is relevant only for SimdResizeChannelFloat (32-bit float channel type).

SimdResizeMethodBicubic 

Bicubic method.

SimdResizeMethodArea 

Area method.

SimdResizeMethodAreaFast 

Area method for previously reduced in 2 times image.

Function Documentation

◆ SimdReduceColor2x2()

void SimdReduceColor2x2 ( const uint8_t *  src,
size_t  srcWidth,
size_t  srcHeight,
size_t  srcStride,
uint8_t *  dst,
size_t  dstWidth,
size_t  dstHeight,
size_t  dstStride,
size_t  channelCount 
)

Performs reducing and Gaussian blurring (in two time) a 8-bit channel color image with using window 2x2.

For input and output image must be performed: dstWidth = (srcWidth + 1)/2, dstHeight = (srcHeight + 1)/2.

For all points:

dst[x, y, c] = (src[2*x, 2*y, c] + src[2*x, 2*y + 1, c] + src[2*x + 1, 2*y, c] + src[2*x + 1, 2*y + 1, c] + 2)/4;
Note
This function has a C++ wrappers: Simd::Reduce2x2(const View<A> & src, View<A> & dst).
Parameters
[in]src- a pointer to pixels data of the original input image.
[in]srcWidth- a width of the input image.
[in]srcHeight- a height of the input image.
[in]srcStride- a row size of the input image.
[out]dst- a pointer to pixels data of the reduced output image.
[in]dstWidth- a width of the output image.
[in]dstHeight- a height of the output image.
[in]dstStride- a row size of the output image.
[in]channelCount- a nmber of channels for input and output images.

◆ SimdReduceGray2x2()

void SimdReduceGray2x2 ( const uint8_t *  src,
size_t  srcWidth,
size_t  srcHeight,
size_t  srcStride,
uint8_t *  dst,
size_t  dstWidth,
size_t  dstHeight,
size_t  dstStride 
)

Performs reducing and Gaussian blurring (in two time) a 8-bit gray image with using window 2x2.

For input and output image must be performed: dstWidth = (srcWidth + 1)/2, dstHeight = (srcHeight + 1)/2.

For all points:

dst[x, y] = (src[2*x, 2*y] + src[2*x, 2*y + 1] + src[2*x + 1, 2*y] + src[2*x + 1, 2*y + 1] + 2)/4;
Note
This function has a C++ wrappers: Simd::ReduceGray2x2(const View<A>& src, View<A>& dst).
Parameters
[in]src- a pointer to pixels data of the original input image.
[in]srcWidth- a width of the input image.
[in]srcHeight- a height of the input image.
[in]srcStride- a row size of the input image.
[out]dst- a pointer to pixels data of the reduced output image.
[in]dstWidth- a width of the output image.
[in]dstHeight- a height of the output image.
[in]dstStride- a row size of the output image.

◆ SimdReduceGray3x3()

void SimdReduceGray3x3 ( const uint8_t *  src,
size_t  srcWidth,
size_t  srcHeight,
size_t  srcStride,
uint8_t *  dst,
size_t  dstWidth,
size_t  dstHeight,
size_t  dstStride,
int  compensation 
)

Performs reducing and Gaussian blurring (in two time) a 8-bit gray image with using window 3x3.

For input and output image must be performed: dstWidth = (srcWidth + 1)/2, dstHeight = (srcHeight + 1)/2.

For every point:

dst[x, y] = (src[2*x-1, 2*y-1] + 2*src[2*x, 2*y-1] + src[2*x+1, 2*y-1] +
          2*(src[2*x-1, 2*y]   + 2*src[2*x, 2*y]   + src[2*x+1, 2*y]) +
             src[2*x-1, 2*y+1] + 2*src[2*x, 2*y+1] + src[2*x+1, 2*y+1] + compensation ? 8 : 0) / 16;
Note
This function has a C++ wrappers: Simd::ReduceGray3x3(const View<A>& src, View<A>& dst, bool compensation).
Parameters
[in]src- a pointer to pixels data of the original input image.
[in]srcWidth- a width of the input image.
[in]srcHeight- a height of the input image.
[in]srcStride- a row size of the input image.
[out]dst- a pointer to pixels data of the reduced output image.
[in]dstWidth- a width of the output image.
[in]dstHeight- a height of the output image.
[in]dstStride- a row size of the output image.
[in]compensation- a flag of compensation of rounding.

◆ SimdReduceGray4x4()

void SimdReduceGray4x4 ( const uint8_t *  src,
size_t  srcWidth,
size_t  srcHeight,
size_t  srcStride,
uint8_t *  dst,
size_t  dstWidth,
size_t  dstHeight,
size_t  dstStride 
)

Performs reducing and Gaussian blurring (in two time) a 8-bit gray image with using window 4x4.

For input and output image must be performed: dstWidth = (srcWidth + 1)/2, dstHeight = (srcHeight + 1)/2.

For every point:

dst[x, y] = (src[2*x-1, 2*y-1] + 3*src[2*x, 2*y-1] + 3*src[2*x+1, 2*y-1] + src[2*x+2, 2*y-1]
          3*(src[2*x-1, 2*y]   + 3*src[2*x, 2*y]   + 3*src[2*x+1, 2*y]   + src[2*x+2, 2*y]) +
          3*(src[2*x-1, 2*y+1] + 3*src[2*x, 2*y+1] + 3*src[2*x+1, 2*y+1] + src[2*x+2, 2*y+1]) +
             src[2*x-1, 2*y+2] + 3*src[2*x, 2*y+2] + 3*src[2*x+1, 2*y+2] + src[2*x+2, 2*y+2] + 32) / 64;
Note
This function has a C++ wrappers: Simd::ReduceGray4x4(const View<A>& src, View<A>& dst).
Parameters
[in]src- a pointer to pixels data of the original input image.
[in]srcWidth- a width of the input image.
[in]srcHeight- a height of the input image.
[in]srcStride- a row size of the input image.
[out]dst- a pointer to pixels data of the reduced output image.
[in]dstWidth- a width of the output image.
[in]dstHeight- a height of the output image.
[in]dstStride- a row size of the output image.

◆ SimdReduceGray5x5()

void SimdReduceGray5x5 ( const uint8_t *  src,
size_t  srcWidth,
size_t  srcHeight,
size_t  srcStride,
uint8_t *  dst,
size_t  dstWidth,
size_t  dstHeight,
size_t  dstStride,
int  compensation 
)

Performs reducing and Gaussian blurring (in two time) a 8-bit gray image with using window 5x5.

For input and output image must be performed: dstWidth = (srcWidth + 1)/2, dstHeight = (srcHeight + 1)/2.

For every point:

dst[x, y] = (
       src[2*x-2, 2*y-2] + 4*src[2*x-1, 2*y-2] + 6*src[2*x, 2*y-2] + 4*src[2*x+1, 2*y-2] + src[2*x+2, 2*y-2] +
    4*(src[2*x-2, 2*y-1] + 4*src[2*x-1, 2*y-1] + 6*src[2*x, 2*y-1] + 4*src[2*x+1, 2*y-1] + src[2*x+2, 2*y-1]) +
    6*(src[2*x-2, 2*y]   + 4*src[2*x-1, 2*y]   + 6*src[2*x, 2*y]   + 4*src[2*x+1, 2*y]   + src[2*x+2, 2*y]) +
    4*(src[2*x-2, 2*y+1] + 4*src[2*x-1, 2*y+1] + 6*src[2*x, 2*y+1] + 4*src[2*x+1, 2*y+1] + src[2*x+2, 2*y+1]) +
       src[2*x-2, 2*y+2] + 4*src[2*x-1, 2*y+2] + 6*src[2*x, 2*y+2] + 4*src[2*x+1, 2*y+2] + src[2*x+2, 2*y+2] +
    compensation ? 128 : 0) / 256;
Note
This function has a C++ wrappers: Simd::ReduceGray5x5(const Viewc<A>& src, View<A>& dst, bool compensation).
Parameters
[in]src- a pointer to pixels data of the original input image.
[in]srcWidth- a width of the input image.
[in]srcHeight- a height of the input image.
[in]srcStride- a row size of the input image.
[out]dst- a pointer to pixels data of the reduced output image.
[in]dstWidth- a width of the output image.
[in]dstHeight- a height of the output image.
[in]dstStride- a row size of the output image.
[in]compensation- a flag of compensation of rounding.

◆ SimdResizerInit()

void * SimdResizerInit ( size_t  srcX,
size_t  srcY,
size_t  dstX,
size_t  dstY,
size_t  channels,
SimdResizeChannelType  type,
SimdResizeMethodType  method 
)

Creates resize context.

An using example (resize of RGBA64 image):

void * resizer = SimdResizerInit(srcX, srcY, dstX, dstY, 4, SimdResizeChannelShort, SimdResizeMethodBilinear);
if (resizer)
{
     SimdResizerRun(resizer, (uint8_t*)src, srcStride, (uint8_t*)dst, dstStride);
     SimdRelease(resizer);
}
Parameters
[in]srcX- a width of the input image.
[in]srcY- a height of the input image.
[in]dstX- a width of the output image.
[in]dstY- a height of the output image.
[in]channels- a channel number of input and output image.
[in]type- a type of input and output image channel.
[in]method- a method used in order to resize image.
Returns
a pointer to resize context. On error it returns NULL. This pointer is used in functions SimdResizerRun. It must be released with using of function SimdRelease.

◆ SimdResizerRun()

void SimdResizerRun ( const void *  resizer,
const uint8_t *  src,
size_t  srcStride,
uint8_t *  dst,
size_t  dstStride 
)

Performs image resizing.

Parameters
[in]resizer- a resize context. It must be created by function SimdResizerInit and released by function SimdRelease.
[in]src- a pointer to pixels data of the original input image.
[in]srcStride- a row size (in bytes) of the input image.
[out]dst- a pointer to pixels data of the resized output image.
[in]dstStride- a row size (in bytes) of the output image.

◆ SimdStretchGray2x2()

void SimdStretchGray2x2 ( const uint8_t *  src,
size_t  srcWidth,
size_t  srcHeight,
size_t  srcStride,
uint8_t *  dst,
size_t  dstWidth,
size_t  dstHeight,
size_t  dstStride 
)

Stretches input 8-bit gray image in two times.

Note
This function has a C++ wrappers: Simd::StretchGray2x2(const View<A>& src, View<A>& dst).
Parameters
[in]src- a pointer to pixels data of the original input image.
[in]srcWidth- a width of the input image.
[in]srcHeight- a height of the input image.
[in]srcStride- a row size of the input image.
[out]dst- a pointer to pixels data of the stretched output image.
[in]dstWidth- a width of the output image.
[in]dstHeight- a height of the output image.
[in]dstStride- a row size of the output image.

◆ ReduceGray2x2()

void ReduceGray2x2 ( const View< A > &  src,
View< A > &  dst 
)

Performs reducing (in 2 times) and Gaussian blurring a 8-bit gray image with using window 2x2.

For input and output image must be performed: dst.width = (src.width + 1)/2, dst.height = (src.height + 1)/2.

For all points:

dst[x, y] = (src[2*x, 2*y] + src[2*x, 2*y + 1] + src[2*x + 1, 2*y] + src[2*x + 1, 2*y + 1] + 2)/4;
Note
This function is a C++ wrapper for function SimdReduceGray2x2.
Parameters
[in]src- an original input image.
[out]dst- a reduced output image.

◆ ReduceGray3x3()

void ReduceGray3x3 ( const View< A > &  src,
View< A > &  dst,
bool  compensation = true 
)

Performs reducing (in 2 times) and Gaussian blurring a 8-bit gray image with using window 3x3.

For input and output image must be performed: dst.width = (src.width + 1)/2, dst.height = (src.height + 1)/2.

For every point:

dst[x, y] = (src[2*x-1, 2*y-1] + 2*src[2*x, 2*y-1] + src[2*x+1, 2*y-1] +
          2*(src[2*x-1, 2*y]   + 2*src[2*x, 2*y]   + src[2*x+1, 2*y]) +
             src[2*x-1, 2*y+1] + 2*src[2*x, 2*y+1] + src[2*x+1, 2*y+1] + compensation ? 8 : 0) / 16;
Note
This function is a C++ wrapper for function SimdReduceGray3x3.
Parameters
[in]src- an original input image.
[out]dst- a reduced output image.
[in]compensation- a flag of compensation of rounding. It is equal to 'true' by default.

◆ ReduceGray4x4()

void ReduceGray4x4 ( const View< A > &  src,
View< A > &  dst 
)

Performs reducing (in 2 times) and Gaussian blurring a 8-bit gray image with using window 4x4.

For input and output image must be performed: dst.width = (src.width + 1)/2, dst.height = (src.height + 1)/2.

For every point:

dst[x, y] =   (src[2*x-1, 2*y-1] + 3*src[2*x, 2*y-1] + 3*src[2*x+1, 2*y-1] + src[2*x+2, 2*y-1]
            3*(src[2*x-1, 2*y]   + 3*src[2*x, 2*y]   + 3*src[2*x+1, 2*y]   + src[2*x+2, 2*y]) +
            3*(src[2*x-1, 2*y+1] + 3*src[2*x, 2*y+1] + 3*src[2*x+1, 2*y+1] + src[2*x+2, 2*y+1]) +
               src[2*x-1, 2*y+2] + 3*src[2*x, 2*y+2] + 3*src[2*x+1, 2*y+2] + src[2*x+2, 2*y+2] + 32) / 64;
Note
This function is a C++ wrapper for function SimdReduceGray4x4.
Parameters
[in]src- an original input image.
[out]dst- a reduced output image.

◆ ReduceGray5x5()

void ReduceGray5x5 ( const View< A > &  src,
View< A > &  dst,
bool  compensation = true 
)

Performs reducing (in 2 times) and Gaussian blurring a 8-bit gray image with using window 5x5.

For input and output image must be performed: dst.width = (src.width + 1)/2, dst.height = (src.height + 1)/2.

For every point:

dst[x, y] = (
       src[2*x-2, 2*y-2] + 4*src[2*x-1, 2*y-2] + 6*src[2*x, 2*y-2] + 4*src[2*x+1, 2*y-2] + src[2*x+2, 2*y-2] +
    4*(src[2*x-2, 2*y-1] + 4*src[2*x-1, 2*y-1] + 6*src[2*x, 2*y-1] + 4*src[2*x+1, 2*y-1] + src[2*x+2, 2*y-1]) +
    6*(src[2*x-2, 2*y]   + 4*src[2*x-1, 2*y]   + 6*src[2*x, 2*y]   + 4*src[2*x+1, 2*y]   + src[2*x+2, 2*y]) +
    4*(src[2*x-2, 2*y+1] + 4*src[2*x-1, 2*y+1] + 6*src[2*x, 2*y+1] + 4*src[2*x+1, 2*y+1] + src[2*x+2, 2*y+1]) +
       src[2*x-2, 2*y+2] + 4*src[2*x-1, 2*y+2] + 6*src[2*x, 2*y+2] + 4*src[2*x+1, 2*y+2] + src[2*x+2, 2*y+2] +
    compensation ? 128 : 0) / 256;
Note
This function is a C++ wrapper for function SimdReduceGray5x5.
Parameters
[in]src- an original input image.
[out]dst- a reduced output image.
[in]compensation- a flag of compensation of rounding. It is equal to 'true' by default.

◆ ReduceGray()

void ReduceGray ( const View< A > &  src,
View< A > &  dst,
::SimdReduceType  reduceType,
bool  compensation = true 
)

Performs reducing (in 2 times) and Gaussian blurring a 8-bit gray image.

For input and output image must be performed: dst.width = (src.width + 1)/2, dst.height = (src.height + 1)/2.

Parameters
[in]src- an original input image.
[out]dst- a reduced output image.
[in]reduceType- a type of function used for image reducing.
[in]compensation- a flag of compensation of rounding. It is relevant only for SimdReduce3x3 and SimdReduce5x5. It is equal to 'true' by default.

◆ Reduce2x2()

void Reduce2x2 ( const View< A > &  src,
View< A > &  dst 
)

Performs reducing of image (in 2 times).

For input and output image must be performed: dst.width = (src.width + 1)/2, dst.height = (src.height + 1)/2.

Parameters
[in]src- an original input image.
[out]dst- a reduced output image.

◆ Resize() [1/2]

void Resize ( const View< A > &  src,
View< A > &  dst,
::SimdResizeMethodType  method = ::SimdResizeMethodBilinear 
)

Performs resizing of image.

All images must have the same format.

Parameters
[in]src- an original input image.
[out]dst- a resized output image.
[in]method- a resizing method. By default it is equal to SimdResizeMethodBilinear.

◆ Resize() [2/2]

void Resize ( const View< A > &  src,
View< A > &  dst,
const Point< ptrdiff_t > &  size,
::SimdResizeMethodType  method = ::SimdResizeMethodBilinear 
)

Performs resizing of image.

Parameters
[in]src- an original input image.
[out]dst- a resized output image. The input image can be the output.
[in]size- a size of output image.
[in]method- a resizing method. By default it is equal to SimdResizeMethodBilinear.

◆ StretchGray2x2()

void StretchGray2x2 ( const View< A > &  src,
View< A > &  dst 
)

Stretches input 8-bit gray image in two times.

Note
This function is a C++ wrapper for function SimdStretchGray2x2.
Parameters
[in]src- an original input image.
[out]dst- a stretched output image.