39 struct ThreshType{
typedef TT T; };
41 template<>
struct ThreshType<uint8_t> {
typedef int T; };
42 template<>
struct ThreshType<int16_t> {
typedef int T; };
43 template<>
struct ThreshType<int32_t> {
typedef int T; };
44 template<>
struct ThreshType<float> {
typedef float T; };
45 template<>
struct ThreshType<double> {
typedef double T; };
47 inline float lt_clip_float(
float f) {
return f > 255 ? 255 : f < 0 ? 0 : f; }
49 typedef uint8_t lt_icl8u;
50 typedef int16_t lt_icl16s;
51 typedef int32_t lt_icl32s;
52 typedef float lt_icl32f;
53 typedef double lt_icl64f;
59 template<
class TS,
class TI,
class TD,
class TT,
bool WITH_GAMMA>
60 void fast_lt(
const TS *psrc,
const TI *ii, TD *pdst,
int w,
int h,
int r, TT t,
float gs,
int channel);
65 template<
class TS,
class TI,
class TD,
class TT,
bool WITH_GAMMA>
66 void fast_lt_impl(
const TS *psrc,
const TI *ii, TD *pdst,
int w,
int h,
int r, TT t,
float gs,
int channel){
69 const int dim = r2*r2;
91 #define GET_II(x,y) ii[(x)+(y)*w] 92 #define GET_A(rx,ry,rw,rh) GET_II((rx+rw),(ry+rh)) 93 #define GET_B(rx,ry,rw,rh) GET_II((rx),(ry)) 94 #define GET_C(rx,ry,rw,rh) GET_II((rx+rw),(ry)) 95 #define GET_D(rx,ry,rw,rh) GET_II((rx),(ry+rh)) 97 #define GET_RECT(rx,ry,rw,rh) (GET_B((rx),(ry),(rw),(rh)) - GET_C((rx),(ry),(rw),(rh)) - GET_D((rx),(ry),(rw),(rh)) + GET_A((rx),(ry),(rw),(rh)) + t) 98 #define COMPLEX_STEP(rx,ry,rw,rh) pdst[x+w*y] = (!WITH_GAMMA) ? \ 99 (255 * (psrc[x+w*y]*((rw)*(rh)) > (GET_RECT((rx),(ry),(rw),(rh)))) ) : \ 100 ((TD)lt_clip_float( gs * (psrc[x+w*y] - float(GET_RECT((rx),(ry),(rw),(rh)))/((rw)*(rh)) ) + 128)) 104 for(
int y=0;y<r;++y){
105 for(
int x=0;x<r;++x){
108 for(
int x=r;x<w-r;++x){
111 for(
int x=w-r;x<w;++x){
117 for(
int y=r; y<yEnd; ++y){
119 for(
int x=0;x<r;++x){
124 const TI *B = ii+(y-r)*w;
125 const TI *C = B + r2;
126 const TI *D = B + r2*w;
127 const TI *A = D + r2;
128 const TS *s = psrc+y*w + r;
129 TD *d = pdst+y*w + r;
130 const TS *ends = s+w-r2;
132 #define STEP *d = (!WITH_GAMMA) ? \ 133 (255 * ( (*s*dim) > (*B - *C - *D + *A + t))) : \ 134 ((TD)lt_clip_float( gs * (*s - float(*B - *C - *D + *A + t)/dim ) + 128)) \ 135 ; ++B; ++C; ++D; ++A; ++s; ++d; 138 for(
int n = ((
int)(ends-s)) >> 4; n > 0; --n){
148 for(
int x=w-r;x<w;++x){
154 for(
int y=h-r;y<h;++y){
155 for(
int x=0;x<r;++x){
158 for(
int x=r;x<w-r;++x){
161 for(
int x=w-r;x<w;++x){
176 #define FAST_LT_DEFINITION \ 177 template<class TS, class TI, class TD, class TT, bool WITH_GAMMA> \ 178 void fast_lt(const TS *psrc, const TI *iim, TD *pdst, int w, int h, \ 179 int r, TT t, float gs, int channel){ \ 180 fast_lt_impl<TS,TI,TD,TT,WITH_GAMMA>(psrc,iim,pdst,w,h,r,t,gs,channel); \ 183 #define INST_FAST_LT(TS,TI,TD,WITH_GAMMA) \ 184 template void fast_lt<lt_icl##TS,lt_icl##TI,lt_icl##TD, \ 185 ThreshType<lt_icl##TS>::T,WITH_GAMMA> \ 186 (const lt_icl##TS*, const lt_icl##TI*, lt_icl##TD*, int, int, \ 187 int, ThreshType<lt_icl##TS>::T,float,int) 189 #define INST_FAST_LT_FOR_SRC_TYPE(SRC,WITH_GAMMA) \ 190 INST_FAST_LT(SRC,32s,8u,WITH_GAMMA); \ 191 INST_FAST_LT(SRC,32f,8u,WITH_GAMMA); \ 192 INST_FAST_LT(SRC,64f,8u,WITH_GAMMA); \ 193 INST_FAST_LT(SRC,32s,16s,WITH_GAMMA); \ 194 INST_FAST_LT(SRC,32f,16s,WITH_GAMMA); \ 195 INST_FAST_LT(SRC,64f,16s,WITH_GAMMA); \ 196 INST_FAST_LT(SRC,32s,32s,WITH_GAMMA); \ 197 INST_FAST_LT(SRC,32f,32s,WITH_GAMMA); \ 198 INST_FAST_LT(SRC,64f,32s,WITH_GAMMA); \ 199 INST_FAST_LT(SRC,32s,32f,WITH_GAMMA); \ 200 INST_FAST_LT(SRC,32f,32f,WITH_GAMMA); \ 201 INST_FAST_LT(SRC,64f,32f,WITH_GAMMA); \ 202 INST_FAST_LT(SRC,32s,64f,WITH_GAMMA); \ 203 INST_FAST_LT(SRC,32f,64f,WITH_GAMMA); \ 204 INST_FAST_LT(SRC,64f,64f,WITH_GAMMA); undocument this line if you encounter any issues!
Definition: Any.h:37
ICLQt_API core::Img< T > filter(const core::Img< T > &image, const std::string &filter)
applies a filter operation on the source image (affinity for float)
#define COMPLEX_STEP(rx, ry, rw, rh)
ICLQt_API ImgQ channel(const ImgQ &image, int channel)
picks a specific image channel
void fast_lt(const TS *psrc, const TI *ii, TD *pdst, int w, int h, int r, TT t, float gs, int channel)
Internally used helper function.
void fast_lt_impl(const TS *psrc, const TI *ii, TD *pdst, int w, int h, int r, TT t, float gs, int channel)
Internally used helper function.
Definition: LocalThresholdOpHelpers.h:66