# Do I have to worry about borders when I resize a large image in blocks?

Hi,

If I first divide an image into 4 (2x2) blocks, resize them by 50% in each dimension separately and put them back together, will the image be different from an image directed resized from the original. I mean will I have to worry that borders between blocks will have some artifacts because they now lose neighbors during calculation?

edit retag close merge delete

Sort by ยป oldest newest most voted

i tried to test the case with the code below

#include <iostream>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"

using namespace cv;
using namespace std;

int main()
{

String InterpolationFlags[] = {"INTER_NEAREST","INTER_LINEAR","INTER_CUBIC","INTER_AREA","INTER_LANCZOS4"};

for( int i=0; i < 5; i++)
{

Mat roi1 =img(Rect( 0, 0, img.cols/2, img.rows/2)).clone();
Mat roi2 =img(Rect( img.cols/2, 0, img.cols/2, img.rows/2)).clone();
Mat roi3 =img(Rect( 0, img.rows/2, img.cols/2, img.rows/2)).clone();
Mat roi4 =img(Rect( img.cols/2, img.rows/2, img.cols/2, img.rows/2)).clone();

resize( img, img, Size( img.cols/2, img.rows/2 ),0,0, i);

resize( roi1, roi1, Size( roi1.cols/2, roi1.rows/2 ),0,0, i);
resize( roi2, roi2, Size( roi2.cols/2, roi2.rows/2 ),0,0, i);
resize( roi3, roi3, Size( roi3.cols/2, roi3.rows/2 ),0,0, i);
resize( roi4, roi4, Size( roi4.cols/2, roi4.rows/2 ),0,0, i);

Mat rroi1 =img(Rect( 0, 0, img.cols/2, img.rows/2));
Mat rroi2 =img(Rect( img.cols/2, 0, img.cols/2, img.rows/2));
Mat rroi3 =img(Rect( 0, img.rows/2, img.cols/2, img.rows/2));
Mat rroi4 =img(Rect( img.cols/2, img.rows/2, img.cols/2, img.rows/2));

absdiff(rroi1,roi1,rroi1);
absdiff(rroi2,roi2,rroi2);
absdiff(rroi3,roi3,rroi3);
absdiff(rroi4,roi4,rroi4);

img = img > 0;
imshow(InterpolationFlags[i],img);
waitKey(0);
}
return 0;
}


results

as seen on the result images the answer depends on InterpolationFlags.

more

i made a change on the code. used absdiff to check changes ( thank to @pklab who remind me )

( 2015-11-15 15:34:47 -0600 )edit

Official site

GitHub

Wiki

Documentation