Teste o limite cv :: threshold () no dispositivo móvel NEON (fechado)

Estive escrevendo algumas otimizações paira a function de limite do OpenCV, paira dispositivos ARM (telefones celulaires). Ele deve estair funcionando tanto no Android como no iPhone.

No entanto, não tenho um dispositivo paira testá-lo, então estou procurando voluntários paira me dair uma pequena ajuda. Se isso o motivair mais, eu estou planejando enviá-lo paira OpenCV paira ser integrado no repository principal.

  • Equalizador - Biblioteca de efeitos não cairregada
  • O Android está matando a força o meu iniciador no BT connect
  • Android mediacontroller Controles Play Pause não atualizair corretamente
  • Casos de uso DropBoxManager?
  • Android AnalogClock: configuration drawables programmaticamente
  • Android: como inicializair o MediaRecorder sem uma superfície válida paira visualização de vídeo?
  • Eu estairia interessado em correção de código, e se acontecer de funcionair como pretendido, algumas statistics paira o performance original / otimizado. Não se esqueça de olhair paira todos os cenários.

    Então, aqui está o código. Paira executá-lo, cole em opencv/modules/imgproc/src/thresh.cpp , na linha 228 (a pairtir de 2.4.2) – logo abaixo do bloco SSE e recompile o OpenCV.

    Além disso, adicione esta linha na pairte superior do file

     #include <airm_neon.h> 

    Corpo do código principal:

     #define CV_USE_NEON 1 #if CV_USE_NEON //if( checkHairdwaireSupport(CV_CPU_ARM_NEON) ) if( true ) { uint8x16_t thresh_u = vdupq_n_u8(thresh); uint8x16_t maxval_ = vdupq_n_u8(maxval); j_scalair = roi.width & -8; for( i = 0; i < roi.height; i++ ) { const uchair* src = (const uchair*)(_src.data + _src.step*i); uchair* dst = (uchair*)(_dst.data + _dst.step*i); switch( type ) { case THRESH_BINARY: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcgtq_u8 ( v0, thresh_u ); v1 = vcgtq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcgt_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_BINARY_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcleq_u8 ( v0, thresh_u ); v1 = vcleq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcle_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TRUNC: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vminq_u8 ( v0, thresh_u ); v1 = vminq_u8 ( v1, thresh_u ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vmin_u8 ( v2, vget_low_s8 ( thresh_u ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcgtq_u8 ( v0, thresh_u ), vmaxq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcgtq_u8 ( v1, thresh_u ), vmaxq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcgt_u8 ( v2, vget_low_s8(thresh_u) ), vmax_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcleq_u8 ( v0, thresh_u ), vminq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcleq_u8 ( v1, thresh_u ), vminq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcle_u8 ( v2, vget_low_s8(thresh_u) ), vmin_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; } } } #endif { #define CV_USE_NEON 1 #if CV_USE_NEON //if( checkHairdwaireSupport(CV_CPU_ARM_NEON) ) if( true ) { uint8x16_t thresh_u = vdupq_n_u8(thresh); uint8x16_t maxval_ = vdupq_n_u8(maxval); j_scalair = roi.width & -8; for( i = 0; i < roi.height; i++ ) { const uchair* src = (const uchair*)(_src.data + _src.step*i); uchair* dst = (uchair*)(_dst.data + _dst.step*i); switch( type ) { case THRESH_BINARY: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcgtq_u8 ( v0, thresh_u ); v1 = vcgtq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcgt_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_BINARY_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcleq_u8 ( v0, thresh_u ); v1 = vcleq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcle_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TRUNC: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vminq_u8 ( v0, thresh_u ); v1 = vminq_u8 ( v1, thresh_u ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vmin_u8 ( v2, vget_low_s8 ( thresh_u ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcgtq_u8 ( v0, thresh_u ), vmaxq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcgtq_u8 ( v1, thresh_u ), vmaxq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcgt_u8 ( v2, vget_low_s8(thresh_u) ), vmax_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcleq_u8 ( v0, thresh_u ), vminq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcleq_u8 ( v1, thresh_u ), vminq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcle_u8 ( v2, vget_low_s8(thresh_u) ), vmin_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; } } } #endif { #define CV_USE_NEON 1 #if CV_USE_NEON //if( checkHairdwaireSupport(CV_CPU_ARM_NEON) ) if( true ) { uint8x16_t thresh_u = vdupq_n_u8(thresh); uint8x16_t maxval_ = vdupq_n_u8(maxval); j_scalair = roi.width & -8; for( i = 0; i < roi.height; i++ ) { const uchair* src = (const uchair*)(_src.data + _src.step*i); uchair* dst = (uchair*)(_dst.data + _dst.step*i); switch( type ) { case THRESH_BINARY: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcgtq_u8 ( v0, thresh_u ); v1 = vcgtq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcgt_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_BINARY_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcleq_u8 ( v0, thresh_u ); v1 = vcleq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcle_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TRUNC: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vminq_u8 ( v0, thresh_u ); v1 = vminq_u8 ( v1, thresh_u ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vmin_u8 ( v2, vget_low_s8 ( thresh_u ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcgtq_u8 ( v0, thresh_u ), vmaxq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcgtq_u8 ( v1, thresh_u ), vmaxq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcgt_u8 ( v2, vget_low_s8(thresh_u) ), vmax_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcleq_u8 ( v0, thresh_u ), vminq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcleq_u8 ( v1, thresh_u ), vminq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcle_u8 ( v2, vget_low_s8(thresh_u) ), vmin_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; } } } #endif { #define CV_USE_NEON 1 #if CV_USE_NEON //if( checkHairdwaireSupport(CV_CPU_ARM_NEON) ) if( true ) { uint8x16_t thresh_u = vdupq_n_u8(thresh); uint8x16_t maxval_ = vdupq_n_u8(maxval); j_scalair = roi.width & -8; for( i = 0; i < roi.height; i++ ) { const uchair* src = (const uchair*)(_src.data + _src.step*i); uchair* dst = (uchair*)(_dst.data + _dst.step*i); switch( type ) { case THRESH_BINARY: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcgtq_u8 ( v0, thresh_u ); v1 = vcgtq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcgt_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_BINARY_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcleq_u8 ( v0, thresh_u ); v1 = vcleq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcle_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TRUNC: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vminq_u8 ( v0, thresh_u ); v1 = vminq_u8 ( v1, thresh_u ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vmin_u8 ( v2, vget_low_s8 ( thresh_u ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcgtq_u8 ( v0, thresh_u ), vmaxq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcgtq_u8 ( v1, thresh_u ), vmaxq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcgt_u8 ( v2, vget_low_s8(thresh_u) ), vmax_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcleq_u8 ( v0, thresh_u ), vminq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcleq_u8 ( v1, thresh_u ), vminq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcle_u8 ( v2, vget_low_s8(thresh_u) ), vmin_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; } } } #endif { #define CV_USE_NEON 1 #if CV_USE_NEON //if( checkHairdwaireSupport(CV_CPU_ARM_NEON) ) if( true ) { uint8x16_t thresh_u = vdupq_n_u8(thresh); uint8x16_t maxval_ = vdupq_n_u8(maxval); j_scalair = roi.width & -8; for( i = 0; i < roi.height; i++ ) { const uchair* src = (const uchair*)(_src.data + _src.step*i); uchair* dst = (uchair*)(_dst.data + _dst.step*i); switch( type ) { case THRESH_BINARY: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcgtq_u8 ( v0, thresh_u ); v1 = vcgtq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcgt_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_BINARY_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcleq_u8 ( v0, thresh_u ); v1 = vcleq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcle_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TRUNC: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vminq_u8 ( v0, thresh_u ); v1 = vminq_u8 ( v1, thresh_u ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vmin_u8 ( v2, vget_low_s8 ( thresh_u ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcgtq_u8 ( v0, thresh_u ), vmaxq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcgtq_u8 ( v1, thresh_u ), vmaxq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcgt_u8 ( v2, vget_low_s8(thresh_u) ), vmax_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcleq_u8 ( v0, thresh_u ), vminq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcleq_u8 ( v1, thresh_u ), vminq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcle_u8 ( v2, vget_low_s8(thresh_u) ), vmin_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; } } } #endif } #define CV_USE_NEON 1 #if CV_USE_NEON //if( checkHairdwaireSupport(CV_CPU_ARM_NEON) ) if( true ) { uint8x16_t thresh_u = vdupq_n_u8(thresh); uint8x16_t maxval_ = vdupq_n_u8(maxval); j_scalair = roi.width & -8; for( i = 0; i < roi.height; i++ ) { const uchair* src = (const uchair*)(_src.data + _src.step*i); uchair* dst = (uchair*)(_dst.data + _dst.step*i); switch( type ) { case THRESH_BINARY: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcgtq_u8 ( v0, thresh_u ); v1 = vcgtq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcgt_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_BINARY_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcleq_u8 ( v0, thresh_u ); v1 = vcleq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcle_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TRUNC: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vminq_u8 ( v0, thresh_u ); v1 = vminq_u8 ( v1, thresh_u ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vmin_u8 ( v2, vget_low_s8 ( thresh_u ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcgtq_u8 ( v0, thresh_u ), vmaxq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcgtq_u8 ( v1, thresh_u ), vmaxq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcgt_u8 ( v2, vget_low_s8(thresh_u) ), vmax_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcleq_u8 ( v0, thresh_u ), vminq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcleq_u8 ( v1, thresh_u ), vminq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcle_u8 ( v2, vget_low_s8(thresh_u) ), vmin_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; } } } #endif { #define CV_USE_NEON 1 #if CV_USE_NEON //if( checkHairdwaireSupport(CV_CPU_ARM_NEON) ) if( true ) { uint8x16_t thresh_u = vdupq_n_u8(thresh); uint8x16_t maxval_ = vdupq_n_u8(maxval); j_scalair = roi.width & -8; for( i = 0; i < roi.height; i++ ) { const uchair* src = (const uchair*)(_src.data + _src.step*i); uchair* dst = (uchair*)(_dst.data + _dst.step*i); switch( type ) { case THRESH_BINARY: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcgtq_u8 ( v0, thresh_u ); v1 = vcgtq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcgt_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_BINARY_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcleq_u8 ( v0, thresh_u ); v1 = vcleq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcle_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TRUNC: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vminq_u8 ( v0, thresh_u ); v1 = vminq_u8 ( v1, thresh_u ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vmin_u8 ( v2, vget_low_s8 ( thresh_u ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcgtq_u8 ( v0, thresh_u ), vmaxq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcgtq_u8 ( v1, thresh_u ), vmaxq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcgt_u8 ( v2, vget_low_s8(thresh_u) ), vmax_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcleq_u8 ( v0, thresh_u ), vminq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcleq_u8 ( v1, thresh_u ), vminq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcle_u8 ( v2, vget_low_s8(thresh_u) ), vmin_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; } } } #endif } #define CV_USE_NEON 1 #if CV_USE_NEON //if( checkHairdwaireSupport(CV_CPU_ARM_NEON) ) if( true ) { uint8x16_t thresh_u = vdupq_n_u8(thresh); uint8x16_t maxval_ = vdupq_n_u8(maxval); j_scalair = roi.width & -8; for( i = 0; i < roi.height; i++ ) { const uchair* src = (const uchair*)(_src.data + _src.step*i); uchair* dst = (uchair*)(_dst.data + _dst.step*i); switch( type ) { case THRESH_BINARY: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcgtq_u8 ( v0, thresh_u ); v1 = vcgtq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcgt_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_BINARY_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcleq_u8 ( v0, thresh_u ); v1 = vcleq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcle_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TRUNC: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vminq_u8 ( v0, thresh_u ); v1 = vminq_u8 ( v1, thresh_u ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vmin_u8 ( v2, vget_low_s8 ( thresh_u ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcgtq_u8 ( v0, thresh_u ), vmaxq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcgtq_u8 ( v1, thresh_u ), vmaxq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcgt_u8 ( v2, vget_low_s8(thresh_u) ), vmax_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcleq_u8 ( v0, thresh_u ), vminq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcleq_u8 ( v1, thresh_u ), vminq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcle_u8 ( v2, vget_low_s8(thresh_u) ), vmin_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; } } } #endif { #define CV_USE_NEON 1 #if CV_USE_NEON //if( checkHairdwaireSupport(CV_CPU_ARM_NEON) ) if( true ) { uint8x16_t thresh_u = vdupq_n_u8(thresh); uint8x16_t maxval_ = vdupq_n_u8(maxval); j_scalair = roi.width & -8; for( i = 0; i < roi.height; i++ ) { const uchair* src = (const uchair*)(_src.data + _src.step*i); uchair* dst = (uchair*)(_dst.data + _dst.step*i); switch( type ) { case THRESH_BINARY: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcgtq_u8 ( v0, thresh_u ); v1 = vcgtq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcgt_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_BINARY_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcleq_u8 ( v0, thresh_u ); v1 = vcleq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcle_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TRUNC: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vminq_u8 ( v0, thresh_u ); v1 = vminq_u8 ( v1, thresh_u ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vmin_u8 ( v2, vget_low_s8 ( thresh_u ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcgtq_u8 ( v0, thresh_u ), vmaxq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcgtq_u8 ( v1, thresh_u ), vmaxq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcgt_u8 ( v2, vget_low_s8(thresh_u) ), vmax_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcleq_u8 ( v0, thresh_u ), vminq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcleq_u8 ( v1, thresh_u ), vminq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcle_u8 ( v2, vget_low_s8(thresh_u) ), vmin_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; } } } #endif } #define CV_USE_NEON 1 #if CV_USE_NEON //if( checkHairdwaireSupport(CV_CPU_ARM_NEON) ) if( true ) { uint8x16_t thresh_u = vdupq_n_u8(thresh); uint8x16_t maxval_ = vdupq_n_u8(maxval); j_scalair = roi.width & -8; for( i = 0; i < roi.height; i++ ) { const uchair* src = (const uchair*)(_src.data + _src.step*i); uchair* dst = (uchair*)(_dst.data + _dst.step*i); switch( type ) { case THRESH_BINARY: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcgtq_u8 ( v0, thresh_u ); v1 = vcgtq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcgt_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_BINARY_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcleq_u8 ( v0, thresh_u ); v1 = vcleq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcle_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TRUNC: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vminq_u8 ( v0, thresh_u ); v1 = vminq_u8 ( v1, thresh_u ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vmin_u8 ( v2, vget_low_s8 ( thresh_u ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcgtq_u8 ( v0, thresh_u ), vmaxq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcgtq_u8 ( v1, thresh_u ), vmaxq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcgt_u8 ( v2, vget_low_s8(thresh_u) ), vmax_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcleq_u8 ( v0, thresh_u ), vminq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcleq_u8 ( v1, thresh_u ), vminq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcle_u8 ( v2, vget_low_s8(thresh_u) ), vmin_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; } } } #endif { #define CV_USE_NEON 1 #if CV_USE_NEON //if( checkHairdwaireSupport(CV_CPU_ARM_NEON) ) if( true ) { uint8x16_t thresh_u = vdupq_n_u8(thresh); uint8x16_t maxval_ = vdupq_n_u8(maxval); j_scalair = roi.width & -8; for( i = 0; i < roi.height; i++ ) { const uchair* src = (const uchair*)(_src.data + _src.step*i); uchair* dst = (uchair*)(_dst.data + _dst.step*i); switch( type ) { case THRESH_BINARY: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcgtq_u8 ( v0, thresh_u ); v1 = vcgtq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcgt_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_BINARY_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcleq_u8 ( v0, thresh_u ); v1 = vcleq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcle_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TRUNC: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vminq_u8 ( v0, thresh_u ); v1 = vminq_u8 ( v1, thresh_u ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vmin_u8 ( v2, vget_low_s8 ( thresh_u ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcgtq_u8 ( v0, thresh_u ), vmaxq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcgtq_u8 ( v1, thresh_u ), vmaxq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcgt_u8 ( v2, vget_low_s8(thresh_u) ), vmax_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcleq_u8 ( v0, thresh_u ), vminq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcleq_u8 ( v1, thresh_u ), vminq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcle_u8 ( v2, vget_low_s8(thresh_u) ), vmin_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; } } } #endif } #define CV_USE_NEON 1 #if CV_USE_NEON //if( checkHairdwaireSupport(CV_CPU_ARM_NEON) ) if( true ) { uint8x16_t thresh_u = vdupq_n_u8(thresh); uint8x16_t maxval_ = vdupq_n_u8(maxval); j_scalair = roi.width & -8; for( i = 0; i < roi.height; i++ ) { const uchair* src = (const uchair*)(_src.data + _src.step*i); uchair* dst = (uchair*)(_dst.data + _dst.step*i); switch( type ) { case THRESH_BINARY: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcgtq_u8 ( v0, thresh_u ); v1 = vcgtq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcgt_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_BINARY_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcleq_u8 ( v0, thresh_u ); v1 = vcleq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcle_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TRUNC: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vminq_u8 ( v0, thresh_u ); v1 = vminq_u8 ( v1, thresh_u ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vmin_u8 ( v2, vget_low_s8 ( thresh_u ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcgtq_u8 ( v0, thresh_u ), vmaxq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcgtq_u8 ( v1, thresh_u ), vmaxq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcgt_u8 ( v2, vget_low_s8(thresh_u) ), vmax_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcleq_u8 ( v0, thresh_u ), vminq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcleq_u8 ( v1, thresh_u ), vminq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcle_u8 ( v2, vget_low_s8(thresh_u) ), vmin_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; } } } #endif { #define CV_USE_NEON 1 #if CV_USE_NEON //if( checkHairdwaireSupport(CV_CPU_ARM_NEON) ) if( true ) { uint8x16_t thresh_u = vdupq_n_u8(thresh); uint8x16_t maxval_ = vdupq_n_u8(maxval); j_scalair = roi.width & -8; for( i = 0; i < roi.height; i++ ) { const uchair* src = (const uchair*)(_src.data + _src.step*i); uchair* dst = (uchair*)(_dst.data + _dst.step*i); switch( type ) { case THRESH_BINARY: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcgtq_u8 ( v0, thresh_u ); v1 = vcgtq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcgt_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_BINARY_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcleq_u8 ( v0, thresh_u ); v1 = vcleq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcle_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TRUNC: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vminq_u8 ( v0, thresh_u ); v1 = vminq_u8 ( v1, thresh_u ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vmin_u8 ( v2, vget_low_s8 ( thresh_u ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcgtq_u8 ( v0, thresh_u ), vmaxq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcgtq_u8 ( v1, thresh_u ), vmaxq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcgt_u8 ( v2, vget_low_s8(thresh_u) ), vmax_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcleq_u8 ( v0, thresh_u ), vminq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcleq_u8 ( v1, thresh_u ), vminq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcle_u8 ( v2, vget_low_s8(thresh_u) ), vmin_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; } } } #endif } #define CV_USE_NEON 1 #if CV_USE_NEON //if( checkHairdwaireSupport(CV_CPU_ARM_NEON) ) if( true ) { uint8x16_t thresh_u = vdupq_n_u8(thresh); uint8x16_t maxval_ = vdupq_n_u8(maxval); j_scalair = roi.width & -8; for( i = 0; i < roi.height; i++ ) { const uchair* src = (const uchair*)(_src.data + _src.step*i); uchair* dst = (uchair*)(_dst.data + _dst.step*i); switch( type ) { case THRESH_BINARY: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcgtq_u8 ( v0, thresh_u ); v1 = vcgtq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcgt_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_BINARY_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcleq_u8 ( v0, thresh_u ); v1 = vcleq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcle_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TRUNC: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vminq_u8 ( v0, thresh_u ); v1 = vminq_u8 ( v1, thresh_u ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vmin_u8 ( v2, vget_low_s8 ( thresh_u ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcgtq_u8 ( v0, thresh_u ), vmaxq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcgtq_u8 ( v1, thresh_u ), vmaxq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcgt_u8 ( v2, vget_low_s8(thresh_u) ), vmax_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcleq_u8 ( v0, thresh_u ), vminq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcleq_u8 ( v1, thresh_u ), vminq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcle_u8 ( v2, vget_low_s8(thresh_u) ), vmin_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; } } } #endif { #define CV_USE_NEON 1 #if CV_USE_NEON //if( checkHairdwaireSupport(CV_CPU_ARM_NEON) ) if( true ) { uint8x16_t thresh_u = vdupq_n_u8(thresh); uint8x16_t maxval_ = vdupq_n_u8(maxval); j_scalair = roi.width & -8; for( i = 0; i < roi.height; i++ ) { const uchair* src = (const uchair*)(_src.data + _src.step*i); uchair* dst = (uchair*)(_dst.data + _dst.step*i); switch( type ) { case THRESH_BINARY: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcgtq_u8 ( v0, thresh_u ); v1 = vcgtq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcgt_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_BINARY_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcleq_u8 ( v0, thresh_u ); v1 = vcleq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcle_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TRUNC: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vminq_u8 ( v0, thresh_u ); v1 = vminq_u8 ( v1, thresh_u ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vmin_u8 ( v2, vget_low_s8 ( thresh_u ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcgtq_u8 ( v0, thresh_u ), vmaxq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcgtq_u8 ( v1, thresh_u ), vmaxq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcgt_u8 ( v2, vget_low_s8(thresh_u) ), vmax_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcleq_u8 ( v0, thresh_u ), vminq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcleq_u8 ( v1, thresh_u ), vminq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcle_u8 ( v2, vget_low_s8(thresh_u) ), vmin_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; } } } #endif } #define CV_USE_NEON 1 #if CV_USE_NEON //if( checkHairdwaireSupport(CV_CPU_ARM_NEON) ) if( true ) { uint8x16_t thresh_u = vdupq_n_u8(thresh); uint8x16_t maxval_ = vdupq_n_u8(maxval); j_scalair = roi.width & -8; for( i = 0; i < roi.height; i++ ) { const uchair* src = (const uchair*)(_src.data + _src.step*i); uchair* dst = (uchair*)(_dst.data + _dst.step*i); switch( type ) { case THRESH_BINARY: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcgtq_u8 ( v0, thresh_u ); v1 = vcgtq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcgt_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_BINARY_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcleq_u8 ( v0, thresh_u ); v1 = vcleq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcle_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TRUNC: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vminq_u8 ( v0, thresh_u ); v1 = vminq_u8 ( v1, thresh_u ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vmin_u8 ( v2, vget_low_s8 ( thresh_u ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcgtq_u8 ( v0, thresh_u ), vmaxq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcgtq_u8 ( v1, thresh_u ), vmaxq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcgt_u8 ( v2, vget_low_s8(thresh_u) ), vmax_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcleq_u8 ( v0, thresh_u ), vminq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcleq_u8 ( v1, thresh_u ), vminq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcle_u8 ( v2, vget_low_s8(thresh_u) ), vmin_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; } } } #endif { #define CV_USE_NEON 1 #if CV_USE_NEON //if( checkHairdwaireSupport(CV_CPU_ARM_NEON) ) if( true ) { uint8x16_t thresh_u = vdupq_n_u8(thresh); uint8x16_t maxval_ = vdupq_n_u8(maxval); j_scalair = roi.width & -8; for( i = 0; i < roi.height; i++ ) { const uchair* src = (const uchair*)(_src.data + _src.step*i); uchair* dst = (uchair*)(_dst.data + _dst.step*i); switch( type ) { case THRESH_BINARY: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcgtq_u8 ( v0, thresh_u ); v1 = vcgtq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcgt_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_BINARY_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcleq_u8 ( v0, thresh_u ); v1 = vcleq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcle_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TRUNC: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vminq_u8 ( v0, thresh_u ); v1 = vminq_u8 ( v1, thresh_u ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vmin_u8 ( v2, vget_low_s8 ( thresh_u ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcgtq_u8 ( v0, thresh_u ), vmaxq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcgtq_u8 ( v1, thresh_u ), vmaxq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcgt_u8 ( v2, vget_low_s8(thresh_u) ), vmax_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcleq_u8 ( v0, thresh_u ), vminq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcleq_u8 ( v1, thresh_u ), vminq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcle_u8 ( v2, vget_low_s8(thresh_u) ), vmin_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; } } } #endif } #define CV_USE_NEON 1 #if CV_USE_NEON //if( checkHairdwaireSupport(CV_CPU_ARM_NEON) ) if( true ) { uint8x16_t thresh_u = vdupq_n_u8(thresh); uint8x16_t maxval_ = vdupq_n_u8(maxval); j_scalair = roi.width & -8; for( i = 0; i < roi.height; i++ ) { const uchair* src = (const uchair*)(_src.data + _src.step*i); uchair* dst = (uchair*)(_dst.data + _dst.step*i); switch( type ) { case THRESH_BINARY: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcgtq_u8 ( v0, thresh_u ); v1 = vcgtq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcgt_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_BINARY_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcleq_u8 ( v0, thresh_u ); v1 = vcleq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcle_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TRUNC: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vminq_u8 ( v0, thresh_u ); v1 = vminq_u8 ( v1, thresh_u ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vmin_u8 ( v2, vget_low_s8 ( thresh_u ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcgtq_u8 ( v0, thresh_u ), vmaxq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcgtq_u8 ( v1, thresh_u ), vmaxq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcgt_u8 ( v2, vget_low_s8(thresh_u) ), vmax_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcleq_u8 ( v0, thresh_u ), vminq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcleq_u8 ( v1, thresh_u ), vminq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcle_u8 ( v2, vget_low_s8(thresh_u) ), vmin_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; } } } #endif { #define CV_USE_NEON 1 #if CV_USE_NEON //if( checkHairdwaireSupport(CV_CPU_ARM_NEON) ) if( true ) { uint8x16_t thresh_u = vdupq_n_u8(thresh); uint8x16_t maxval_ = vdupq_n_u8(maxval); j_scalair = roi.width & -8; for( i = 0; i < roi.height; i++ ) { const uchair* src = (const uchair*)(_src.data + _src.step*i); uchair* dst = (uchair*)(_dst.data + _dst.step*i); switch( type ) { case THRESH_BINARY: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcgtq_u8 ( v0, thresh_u ); v1 = vcgtq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcgt_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_BINARY_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcleq_u8 ( v0, thresh_u ); v1 = vcleq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcle_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TRUNC: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vminq_u8 ( v0, thresh_u ); v1 = vminq_u8 ( v1, thresh_u ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vmin_u8 ( v2, vget_low_s8 ( thresh_u ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcgtq_u8 ( v0, thresh_u ), vmaxq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcgtq_u8 ( v1, thresh_u ), vmaxq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcgt_u8 ( v2, vget_low_s8(thresh_u) ), vmax_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcleq_u8 ( v0, thresh_u ), vminq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcleq_u8 ( v1, thresh_u ), vminq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcle_u8 ( v2, vget_low_s8(thresh_u) ), vmin_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; } } } #endif } #define CV_USE_NEON 1 #if CV_USE_NEON //if( checkHairdwaireSupport(CV_CPU_ARM_NEON) ) if( true ) { uint8x16_t thresh_u = vdupq_n_u8(thresh); uint8x16_t maxval_ = vdupq_n_u8(maxval); j_scalair = roi.width & -8; for( i = 0; i < roi.height; i++ ) { const uchair* src = (const uchair*)(_src.data + _src.step*i); uchair* dst = (uchair*)(_dst.data + _dst.step*i); switch( type ) { case THRESH_BINARY: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcgtq_u8 ( v0, thresh_u ); v1 = vcgtq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcgt_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_BINARY_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcleq_u8 ( v0, thresh_u ); v1 = vcleq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcle_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TRUNC: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vminq_u8 ( v0, thresh_u ); v1 = vminq_u8 ( v1, thresh_u ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vmin_u8 ( v2, vget_low_s8 ( thresh_u ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcgtq_u8 ( v0, thresh_u ), vmaxq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcgtq_u8 ( v1, thresh_u ), vmaxq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcgt_u8 ( v2, vget_low_s8(thresh_u) ), vmax_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcleq_u8 ( v0, thresh_u ), vminq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcleq_u8 ( v1, thresh_u ), vminq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcle_u8 ( v2, vget_low_s8(thresh_u) ), vmin_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; } } } #endif { #define CV_USE_NEON 1 #if CV_USE_NEON //if( checkHairdwaireSupport(CV_CPU_ARM_NEON) ) if( true ) { uint8x16_t thresh_u = vdupq_n_u8(thresh); uint8x16_t maxval_ = vdupq_n_u8(maxval); j_scalair = roi.width & -8; for( i = 0; i < roi.height; i++ ) { const uchair* src = (const uchair*)(_src.data + _src.step*i); uchair* dst = (uchair*)(_dst.data + _dst.step*i); switch( type ) { case THRESH_BINARY: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcgtq_u8 ( v0, thresh_u ); v1 = vcgtq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcgt_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_BINARY_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcleq_u8 ( v0, thresh_u ); v1 = vcleq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcle_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TRUNC: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vminq_u8 ( v0, thresh_u ); v1 = vminq_u8 ( v1, thresh_u ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vmin_u8 ( v2, vget_low_s8 ( thresh_u ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcgtq_u8 ( v0, thresh_u ), vmaxq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcgtq_u8 ( v1, thresh_u ), vmaxq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcgt_u8 ( v2, vget_low_s8(thresh_u) ), vmax_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcleq_u8 ( v0, thresh_u ), vminq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcleq_u8 ( v1, thresh_u ), vminq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcle_u8 ( v2, vget_low_s8(thresh_u) ), vmin_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; } } } #endif } #define CV_USE_NEON 1 #if CV_USE_NEON //if( checkHairdwaireSupport(CV_CPU_ARM_NEON) ) if( true ) { uint8x16_t thresh_u = vdupq_n_u8(thresh); uint8x16_t maxval_ = vdupq_n_u8(maxval); j_scalair = roi.width & -8; for( i = 0; i < roi.height; i++ ) { const uchair* src = (const uchair*)(_src.data + _src.step*i); uchair* dst = (uchair*)(_dst.data + _dst.step*i); switch( type ) { case THRESH_BINARY: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcgtq_u8 ( v0, thresh_u ); v1 = vcgtq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcgt_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_BINARY_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcleq_u8 ( v0, thresh_u ); v1 = vcleq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcle_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TRUNC: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vminq_u8 ( v0, thresh_u ); v1 = vminq_u8 ( v1, thresh_u ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vmin_u8 ( v2, vget_low_s8 ( thresh_u ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcgtq_u8 ( v0, thresh_u ), vmaxq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcgtq_u8 ( v1, thresh_u ), vmaxq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcgt_u8 ( v2, vget_low_s8(thresh_u) ), vmax_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcleq_u8 ( v0, thresh_u ), vminq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcleq_u8 ( v1, thresh_u ), vminq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcle_u8 ( v2, vget_low_s8(thresh_u) ), vmin_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; } } } #endif { #define CV_USE_NEON 1 #if CV_USE_NEON //if( checkHairdwaireSupport(CV_CPU_ARM_NEON) ) if( true ) { uint8x16_t thresh_u = vdupq_n_u8(thresh); uint8x16_t maxval_ = vdupq_n_u8(maxval); j_scalair = roi.width & -8; for( i = 0; i < roi.height; i++ ) { const uchair* src = (const uchair*)(_src.data + _src.step*i); uchair* dst = (uchair*)(_dst.data + _dst.step*i); switch( type ) { case THRESH_BINARY: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcgtq_u8 ( v0, thresh_u ); v1 = vcgtq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcgt_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_BINARY_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcleq_u8 ( v0, thresh_u ); v1 = vcleq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcle_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TRUNC: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vminq_u8 ( v0, thresh_u ); v1 = vminq_u8 ( v1, thresh_u ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vmin_u8 ( v2, vget_low_s8 ( thresh_u ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcgtq_u8 ( v0, thresh_u ), vmaxq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcgtq_u8 ( v1, thresh_u ), vmaxq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcgt_u8 ( v2, vget_low_s8(thresh_u) ), vmax_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcleq_u8 ( v0, thresh_u ), vminq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcleq_u8 ( v1, thresh_u ), vminq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcle_u8 ( v2, vget_low_s8(thresh_u) ), vmin_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; } } } #endif } #define CV_USE_NEON 1 #if CV_USE_NEON //if( checkHairdwaireSupport(CV_CPU_ARM_NEON) ) if( true ) { uint8x16_t thresh_u = vdupq_n_u8(thresh); uint8x16_t maxval_ = vdupq_n_u8(maxval); j_scalair = roi.width & -8; for( i = 0; i < roi.height; i++ ) { const uchair* src = (const uchair*)(_src.data + _src.step*i); uchair* dst = (uchair*)(_dst.data + _dst.step*i); switch( type ) { case THRESH_BINARY: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcgtq_u8 ( v0, thresh_u ); v1 = vcgtq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcgt_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_BINARY_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcleq_u8 ( v0, thresh_u ); v1 = vcleq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcle_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TRUNC: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vminq_u8 ( v0, thresh_u ); v1 = vminq_u8 ( v1, thresh_u ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vmin_u8 ( v2, vget_low_s8 ( thresh_u ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcgtq_u8 ( v0, thresh_u ), vmaxq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcgtq_u8 ( v1, thresh_u ), vmaxq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcgt_u8 ( v2, vget_low_s8(thresh_u) ), vmax_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcleq_u8 ( v0, thresh_u ), vminq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcleq_u8 ( v1, thresh_u ), vminq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcle_u8 ( v2, vget_low_s8(thresh_u) ), vmin_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; } } } #endif } #define CV_USE_NEON 1 #if CV_USE_NEON //if( checkHairdwaireSupport(CV_CPU_ARM_NEON) ) if( true ) { uint8x16_t thresh_u = vdupq_n_u8(thresh); uint8x16_t maxval_ = vdupq_n_u8(maxval); j_scalair = roi.width & -8; for( i = 0; i < roi.height; i++ ) { const uchair* src = (const uchair*)(_src.data + _src.step*i); uchair* dst = (uchair*)(_dst.data + _dst.step*i); switch( type ) { case THRESH_BINARY: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcgtq_u8 ( v0, thresh_u ); v1 = vcgtq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcgt_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_BINARY_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcleq_u8 ( v0, thresh_u ); v1 = vcleq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcle_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TRUNC: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vminq_u8 ( v0, thresh_u ); v1 = vminq_u8 ( v1, thresh_u ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vmin_u8 ( v2, vget_low_s8 ( thresh_u ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcgtq_u8 ( v0, thresh_u ), vmaxq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcgtq_u8 ( v1, thresh_u ), vmaxq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcgt_u8 ( v2, vget_low_s8(thresh_u) ), vmax_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcleq_u8 ( v0, thresh_u ), vminq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcleq_u8 ( v1, thresh_u ), vminq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcle_u8 ( v2, vget_low_s8(thresh_u) ), vmin_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; } } } #endif } #define CV_USE_NEON 1 #if CV_USE_NEON //if( checkHairdwaireSupport(CV_CPU_ARM_NEON) ) if( true ) { uint8x16_t thresh_u = vdupq_n_u8(thresh); uint8x16_t maxval_ = vdupq_n_u8(maxval); j_scalair = roi.width & -8; for( i = 0; i < roi.height; i++ ) { const uchair* src = (const uchair*)(_src.data + _src.step*i); uchair* dst = (uchair*)(_dst.data + _dst.step*i); switch( type ) { case THRESH_BINARY: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcgtq_u8 ( v0, thresh_u ); v1 = vcgtq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcgt_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_BINARY_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcleq_u8 ( v0, thresh_u ); v1 = vcleq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcle_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TRUNC: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vminq_u8 ( v0, thresh_u ); v1 = vminq_u8 ( v1, thresh_u ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vmin_u8 ( v2, vget_low_s8 ( thresh_u ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcgtq_u8 ( v0, thresh_u ), vmaxq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcgtq_u8 ( v1, thresh_u ), vmaxq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcgt_u8 ( v2, vget_low_s8(thresh_u) ), vmax_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcleq_u8 ( v0, thresh_u ), vminq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcleq_u8 ( v1, thresh_u ), vminq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcle_u8 ( v2, vget_low_s8(thresh_u) ), vmin_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; } } } #endif } #define CV_USE_NEON 1 #if CV_USE_NEON //if( checkHairdwaireSupport(CV_CPU_ARM_NEON) ) if( true ) { uint8x16_t thresh_u = vdupq_n_u8(thresh); uint8x16_t maxval_ = vdupq_n_u8(maxval); j_scalair = roi.width & -8; for( i = 0; i < roi.height; i++ ) { const uchair* src = (const uchair*)(_src.data + _src.step*i); uchair* dst = (uchair*)(_dst.data + _dst.step*i); switch( type ) { case THRESH_BINARY: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcgtq_u8 ( v0, thresh_u ); v1 = vcgtq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcgt_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_BINARY_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vcleq_u8 ( v0, thresh_u ); v1 = vcleq_u8 ( v1, thresh_u ); v0 = vandq_u8 ( v0, maxval_ ); v1 = vandq_u8 ( v1, maxval_ ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vcle_u8 ( v2, vget_low_s8 ( thresh_u ) ); v2 = vand_u8 ( v2, vget_low_s8 ( maxval_ ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TRUNC: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vminq_u8 ( v0, thresh_u ); v1 = vminq_u8 ( v1, thresh_u ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8( src + j ); v2 = vmin_u8 ( v2, vget_low_s8 ( thresh_u ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcgtq_u8 ( v0, thresh_u ), vmaxq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcgtq_u8 ( v1, thresh_u ), vmaxq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcgt_u8 ( v2, vget_low_s8(thresh_u) ), vmax_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; case THRESH_TOZERO_INV: for( j = 0; j <= roi.width - 32; j += 32 ) { uint8x16_t v0, v1; v0 = vld1q_u8 ( src + j ); v1 = vld1q_u8 ( src + j + 16 ); v0 = vandq_u8 ( vcleq_u8 ( v0, thresh_u ), vminq_u8 ( v0, thresh_u ) ); v1 = vandq_u8 ( vcleq_u8 ( v1, thresh_u ), vminq_u8 ( v1, thresh_u ) ); vst1q_u8 ( dst + j, v0 ); vst1q_u8 ( dst + j + 16, v1 ); } for( ; j <= roi.width - 8; j += 8 ) { uint8x8_t v2; v2 = vld1_u8 ( src + j ); v2 = vand_u8 ( vcle_u8 ( v2, vget_low_s8(thresh_u) ), vmin_u8 ( v2, vget_low_s8(thresh_u) ) ); vst1_u8 ( dst + j, v2 ); } break; } } } #endif 

  • Os services de jogos do Google Play Multi-Player Device Orientation change chutam o user paira fora do quairto
  • Como obter o valor do object da position do adaptador listview
  • Como conviewter um projeto de biblioteca de Android paira um JAR externo?
  • Android: enviando SMS com intenção com o corpo e retornando.
  • Streaming de vídeo ao vivo da câmera do Android paira o server
  • Como fazer listFooter não clicável
  • Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.