| 138 | |
| 139 | |
| 140 | void FilterEngine::init( const Ptr<BaseFilter>& _filter2D, |
| 141 | const Ptr<BaseRowFilter>& _rowFilter, |
| 142 | const Ptr<BaseColumnFilter>& _columnFilter, |
| 143 | int _srcType, int _dstType, int _bufType, |
| 144 | int _rowBorderType, int _columnBorderType, |
| 145 | const Scalar& _borderValue ) |
| 146 | { |
| 147 | _srcType = CV_MAT_TYPE(_srcType); |
| 148 | _bufType = CV_MAT_TYPE(_bufType); |
| 149 | _dstType = CV_MAT_TYPE(_dstType); |
| 150 | |
| 151 | srcType = _srcType; |
| 152 | int srcElemSize = (int)getElemSize(srcType); |
| 153 | dstType = _dstType; |
| 154 | bufType = _bufType; |
| 155 | |
| 156 | filter2D = _filter2D; |
| 157 | rowFilter = _rowFilter; |
| 158 | columnFilter = _columnFilter; |
| 159 | |
| 160 | if( _columnBorderType < 0 ) |
| 161 | _columnBorderType = _rowBorderType; |
| 162 | |
| 163 | rowBorderType = _rowBorderType; |
| 164 | columnBorderType = _columnBorderType; |
| 165 | |
| 166 | CV_Assert( columnBorderType != BORDER_WRAP ); |
| 167 | |
| 168 | if( isSeparable() ) |
| 169 | { |
| 170 | CV_Assert( !rowFilter.empty() && !columnFilter.empty() ); |
| 171 | ksize = Size(rowFilter->ksize, columnFilter->ksize); |
| 172 | anchor = Point(rowFilter->anchor, columnFilter->anchor); |
| 173 | } |
| 174 | else |
| 175 | { |
| 176 | CV_Assert( bufType == srcType ); |
| 177 | ksize = filter2D->ksize; |
| 178 | anchor = filter2D->anchor; |
| 179 | } |
| 180 | |
| 181 | CV_Assert( 0 <= anchor.x && anchor.x < ksize.width && |
| 182 | 0 <= anchor.y && anchor.y < ksize.height ); |
| 183 | |
| 184 | borderElemSize = srcElemSize/(CV_MAT_DEPTH(srcType) >= CV_32S ? sizeof(int) : 1); |
| 185 | int borderLength = std::max(ksize.width - 1, 1); |
| 186 | borderTab.resize(borderLength*borderElemSize); |
| 187 | |
| 188 | maxWidth = bufStep = 0; |
| 189 | constBorderRow.clear(); |
| 190 | |
| 191 | if( rowBorderType == BORDER_CONSTANT || columnBorderType == BORDER_CONSTANT ) |
| 192 | { |
| 193 | constBorderValue.resize(srcElemSize*borderLength); |
| 194 | int srcType1 = CV_MAKETYPE(CV_MAT_DEPTH(srcType), MIN(CV_MAT_CN(srcType), 4)); |
| 195 | scalarToRawData(_borderValue, &constBorderValue[0], srcType1, |
| 196 | borderLength*CV_MAT_CN(srcType)); |
| 197 | } |
nothing calls this directly
no test coverage detected