title: Programmatically control zoom Opencv
body: <p>I've written a simple program in OpenCV to open a tiff image. This program is almost identical to <a href="http://docs.opencv.org/doc/tutorials/introduction/display_image/display_image.html" rel="nofollow noreferrer">this</a> post (save for two lines) but I'll add it here for clarity:</p>
  
  <pre><code>#include &lt;opencv2/core/core.hpp&gt;
  #include &lt;opencv2/highgui/highgui.hpp&gt;
  #include &lt;iostream&gt;
  
  using namespace cv;
  using namespace std;
  
  int main( int argc, char** argv )
  {
   if( argc != 2)
   {
   cout &lt;&lt;" Usage: display_image ImageToLoadAndDisplay" &lt;&lt; endl;
   return -1;
   }
  
   Mat image;
   image = imread(argv[1], CV_LOAD_IMAGE_COLOR);   // Read the file
  
   if(! image.data )                              // Check for invalid input
   {
      cout &lt;&lt;  "Could not open or find the image" &lt;&lt; std::endl ;
      return -1;
   }
  
   namedWindow( "Display window", WINDOW_AUTOSIZE );// Create a window for display.
   imshow( "Display window", image );                   // Show our image inside it.
   moveWindow("Display window",0,0); //set window postion to top left
   setWindowProperty("Display window", CV_WND_PROP_FULLSCREEN, CV_WINDOW_FULLSCREEN); //make fullscreen
  
   waitKey(0);                                          // Wait for a keystroke in the window
   return 0;
  </code></pre>
  
  <p>}</p>
  
  <p>I've added two lines to ensure the image opens from the top left and is full screen (the second line may or may not be used in the future). What I would like to do is perform the same action as when I roll the mouse wheel and "zoom" on the image but I'd like to control this precisely so that control a) the position and b) level of zoom for the "blue" window in the following image (achieved by scrolling the mouse normally). <img src="https://i.stack.imgur.com/3sUsk.png" alt="enter image description here">. You'll notice a small grey window at the top of the image indicating how much and where the 'zoomed' in portion of the image currently is. How can I control this 'zoomed' window in code? </p>