How to divide an image in four quadrants and rotate 180 degrees the quadrant 1 and 4 with OpenCV?
<p>So, I have this activity when I have to take an image, divide it into four quadrants and then rotate the quadrants 1 nd four in the same imagen, without creating another window. I have already this code but I just got to make the rotations in differents windows and that's my main issue. If this helps, I made the code in Visual Studio, with a CLR Project. Thank you.</p>

<pre><code>#include "stdafx.h"
#include &lt;iostream&gt;
#include &lt;opencv\cv.h&gt;
#include &lt;opencv\cxcore.h&gt;
#include &lt;opencv\highgui.h&gt;
#include &lt;cmath&gt;

using namespace System;
using namespace std;
using namespace cv;

int main( int argc, char** argv ){ 
    CvPoint pt1, pt2;
    int width; 
    int height; 
    IplImage* img = cvLoadImage("C:/Users/Munii/Documents/Visual Studio 2010/Projects/Proyecto/Proyecto/Imagen.jpg"); 

    pt1.x=0; 
    pt1.y=0; 
    pt2.x = (img-&gt;width)/2; 
    pt2.y = (img-&gt;height)/2; 
    width = img-&gt;width; 
    height = img-&gt;height; 

    IplImage* rotated=cvCreateImage(cvGetSize(img),IPL_DEPTH_8U,img-&gt;nChannels);
    CvPoint2D32f center;
    float angle=180;
    CvMat* M = cvCreateMat(2,3,CV_32FC1);
    center.x = (img-&gt;width)/2.0;
    center.y = (img-&gt;height)/2.0;
    cv2DRotationMatrix(center,angle,1.0,M);
    cvWarpAffine(img,rotated,M,CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS, cvScalarAll(0)); 
    cvSetImageROI(rotated, cvRect( pt1.x, pt1.y, pt2.x, pt2.y)); 

    pt1.x = (img-&gt;width)/2;
    pt1.y = (img-&gt;height)/2;  
    pt2.x = img-&gt;width;
    pt2.y = img-&gt;height;  

    IplImage* rot=cvCreateImage(cvGetSize(img),IPL_DEPTH_8U,img-&gt;nChannels);
    center.x=img-&gt;width/2.0;
    center.y=img-&gt;height/2.0;
    cv2DRotationMatrix(center,angle,1.0,M);
    cvWarpAffine(img,rot,M,CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS, cvScalarAll(0)); 
    cvSetImageROI(rot, cvRect( pt1.x, pt1.y, pt1.x, pt2.y)); 

    cvNamedWindow("Ejemplo 3", CV_WINDOW_AUTOSIZE); //creamos una ventana con el nombre Ejemplo 3
    cvNamedWindow("ROI", CV_WINDOW_AUTOSIZE); 
    cvNamedWindow("RO", CV_WINDOW_AUTOSIZE); //creamos una ventana con el nombre ROI donde estará la región de interes
    cvShowImage("Ejemplo 3", img);
    cvShowImage("ROI",rotated);
    cvShowImage("RO",rot); //mostramos la imagen en la ventana anteriormente creada
    cvSaveImage("C:/Users/Munii/Documents/Visual Studio 2010/Projects/Proyecto/Proyecto/RotacionI.jpg", rotated);
    cvSaveImage("C:/Users/Munii/Documents/Visual Studio 2010/Projects/Proyecto/Proyecto/RotacionIV.jpg", rot);
    cvWaitKey(0);
    cvDestroyWindow("ROI" );
    cvDestroyWindow("RO" );
    cvReleaseImage( &amp;img );
    cvDestroyWindow("Ejemplo3" );    
    cvReleaseImage(&amp;rotated);   
    cvReleaseMat(&amp;M);
}
</code></pre>