OpenCV cropped image distorted

asked 2016-02-26 18:10:02 -0600

bakalolo gravatar image

I am trying to read an image and crop a rectangular region from it using OpenCV. However the cropped image I'm getting seems to be out of proportion and not the same size as the original. Is there something wrong with my code? Or am I doing something stupid like unintentionally zooming in on the window.

#include "opencv2/opencv.hpp"
#include <stdio.h>
#include <iostream>
#include <stdlib.h>


using namespace cv;
using namespace std;

int main()
{

    // Read in an image 1
    Mat Cloud1 = imread("/home/user1/Pictures/cloud1.jpeg");
    Rect rect(250,250,150,150); //some random values
    Mat Template = Cloud1(rect);
    namedWindow("FIGURE 1", CV_WINDOW_AUTOSIZE);
    namedWindow("FIGURE 2", CV_WINDOW_AUTOSIZE);
    imshow("FIGURE 1", Cloud1);
    imshow("FIGURE 2", Template);
    waitKey(0);

    return 0;
}

enter image description here

edit retag flag offensive close merge delete

Comments

could you try

namedWindow("FIGURE 2", CV_WINDOW_AUTOSIZE | CV_GUI_NORMAL);
sturkmen gravatar imagesturkmen ( 2016-02-26 19:18:26 -0600 )edit