diff options
| author | Tim Redfern <tim@eclectronics.org> | 2014-01-23 17:57:37 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2014-01-23 17:57:37 +0000 |
| commit | f533df23fb1cd3044aaa02bf74625e9b53c032c1 (patch) | |
| tree | ed3695dfe02205b4c109317fbcf00298159984f8 /rotord/src/cvimage.h | |
| parent | efebf20348daca798c22cbac770d47e9151f941f (diff) | |
mosaic node
Diffstat (limited to 'rotord/src/cvimage.h')
| -rw-r--r-- | rotord/src/cvimage.h | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/rotord/src/cvimage.h b/rotord/src/cvimage.h index b356f82..25cf3e8 100644 --- a/rotord/src/cvimage.h +++ b/rotord/src/cvimage.h @@ -218,10 +218,38 @@ namespace Rotor { */ return t; } - void crop(int _w,int _h){ //change borders, crop/ extend + void crop(int _w,int _h){ //change borders, crop/ extend, centred + cv::Mat source; + int X,Y,W,H; + //do crop part if ( _w<w||_h<h){ - + //create crop rectangle xywh + X=Y=0; + W=w; + H=h; + if (_w<w){ + W=_w; + X=(w-_w)/2; + w=_w; + } + if (_h<h){ + H=_h; + Y=(h-_h)/2; + h=_h; + } + cv::Mat cropped; + CvRect r=cvRect(X,Y,W,H) ; + rgb(r).copyTo(source); } + else source=rgb; + copyMakeBorder(source,rgb,(_h-h)/2,(_h-h)/2,(_w-w)/2,(_w-w)/2,cv::BORDER_REPLICATE); + w=rgb.rows; + h=rgb.cols; + } + void resize(int _w,int _h){ + cv::resize(rgb,rgb,cv::Size(_w,_h),0,0,cv::INTER_LINEAR ); + w=rgb.rows; + h=rgb.cols; } Image & operator=(const Image &other); //believe these still work, don't know if these optimisations are better than opencvs.. |
