JonasT
JonasT

Reputation: 616

Handle large images in OpenCV

How do i handle large (>15000x15000) images without resizing?

What i need to achieve is: get the pixel value (x,y,r,g,b) on mouse hover. Therefore resizing the image to fit the screen is not an option.

I tried to find an option to add scrollbars, but found none. I also had the idea to show a fixed window size with 100% sized image and drag the image around, but i have no idea how to accomplish that.

I also tried to build OpenCV with QT (as seen here), but failed miserably (uncountable CMake warnings).

Environment: Win 7, VS2013, C++, OpenCV 3.0

Upvotes: 0

Views: 2087

Answers (1)

Unapiedra
Unapiedra

Reputation: 16248

This isn't really an OpenCV problem. My suggestion is that you use the GUI framework of your choice to solve this. Qt would be a very suitable option and it has the nice benefit that integration between OpenCV and Qt is good.

  1. Try to build OpenCV with Qt included. You don't provide details on what went wrong and the link doesn't mention installation at all. But searching for the CMake warnings, or trying to find out how to install Qt on Windows should not be too difficult.
  2. Look into displaying very large images with Qt. It has everything you need already. A quick search found this SO answer which recommends QGraphicsView.

  3. If you have enough memory to store your 15k x 15k image in it, you don't need to use a QGraphicsView and tiling. As mentioned here you should probably be using a QPixmap and then look up the RGB coordinates by a second method.

If memory is an issue

Here is an entry (a bit old) on how to load an image only partially, i.e. not completely into memory. Be aware of the existence of QImageReader.

Upvotes: 2

Related Questions