MCPcopy Create free account
hub / github.com/creatale/node-dv / copyMakeBorder

Method copyMakeBorder

deps/opencv/modules/imgproc/src/utils.cpp:204–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202}
203
204void cv::copyMakeBorder( InputArray _src, OutputArray _dst, int top, int bottom,
205 int left, int right, int borderType, const Scalar& value )
206{
207 Mat src = _src.getMat();
208 CV_Assert( top >= 0 && bottom >= 0 && left >= 0 && right >= 0 );
209
210 if( src.isSubmatrix() && (borderType & BORDER_ISOLATED) == 0 )
211 {
212 Size wholeSize;
213 Point ofs;
214 src.locateROI(wholeSize, ofs);
215 int dtop = std::min(ofs.y, top);
216 int dbottom = std::min(wholeSize.height - src.rows - ofs.y, bottom);
217 int dleft = std::min(ofs.x, left);
218 int dright = std::min(wholeSize.width - src.cols - ofs.x, right);
219 src.adjustROI(dtop, dbottom, dleft, dright);
220 top -= dtop;
221 left -= dleft;
222 bottom -= dbottom;
223 right -= dright;
224 }
225
226 _dst.create( src.rows + top + bottom, src.cols + left + right, src.type() );
227 Mat dst = _dst.getMat();
228
229 if(top == 0 && left == 0 && bottom == 0 && right == 0)
230 {
231 if(src.data != dst.data || src.step != dst.step)
232 src.copyTo(dst);
233 return;
234 }
235
236 borderType &= ~BORDER_ISOLATED;
237
238 if( borderType != BORDER_CONSTANT )
239 copyMakeBorder_8u( src.data, src.step, src.size(),
240 dst.data, dst.step, dst.size(),
241 top, left, (int)src.elemSize(), borderType );
242 else
243 {
244 int cn = src.channels(), cn1 = cn;
245 AutoBuffer<double> buf(cn);
246 if( cn > 4 )
247 {
248 CV_Assert( value[0] == value[1] && value[0] == value[2] && value[0] == value[3] );
249 cn1 = 1;
250 }
251 scalarToRawData(value, buf, CV_MAKETYPE(src.depth(), cn1), cn);
252 copyMakeConstBorder_8u( src.data, src.step, src.size(),
253 dst.data, dst.step, dst.size(),
254 top, left, (int)src.elemSize(), (uchar*)(double*)buf );
255 }
256}
257
258
259double cv::PSNR(InputArray _src1, InputArray _src2)

Callers

nothing calls this directly

Calls 14

copyMakeBorder_8uFunction · 0.85
scalarToRawDataFunction · 0.85
copyMakeConstBorder_8uFunction · 0.85
isSubmatrixMethod · 0.80
minFunction · 0.50
getMatMethod · 0.45
locateROIMethod · 0.45
createMethod · 0.45
typeMethod · 0.45
copyToMethod · 0.45
sizeMethod · 0.45
elemSizeMethod · 0.45

Tested by

no test coverage detected