Home Fit zoomed image to window with OpenCV
Reply: 0

Fit zoomed image to window with OpenCV

user1448 Published in June 18, 2018, 8:43 pm

I am using OpenCV (3.3) with the Qt Backend as I want to use the integrated zoom functionality. Now I want to achieve that the zoomed image is fitted to the full window. At the moment the zoomed image is only shown in the area where the initial image was shown which is not optimal, at least when I use vertical images.

What is the best way to do this?

EDIT Example picture:

Full view


In comparison to that the behavior of the standard Xubuntu image viewer. This is the behavior I want to achieve with OpenCV. The zoomed image fills the full window.

Full view image viewer

zoomed view image viewer

#include <string>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>

using namespace std;
using namespace cv;

int annotate(string imageFilePath) {

    Mat img = imread(imageFilePath); 
    if (img.empty()) {
        cout << "Error loading image " << imageFilePath << endl;
        return 0;
    namedWindow("AnnotationTool", cv::WINDOW_GUI_NORMAL);
    imshow("AnnotationTool", img);
    return 0;

int main(int argc, char** argv) {

    if (argc != 2) {
        cout << "Usage: " << argv[0] << " <pathToImage>" << endl;
        return 0;
    string pathToImage = argv[1];
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.249042 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO