We had an image loaded into open CV from some compressed JPG or PNG file. It was really big. We had some ROI on it say from (2000:2000) to (2100:2100) (square 100x100). We closed an image. Could we any how open that ROI again not loading full image file into memory? If yes what shall we do for it? Any metadata to save?
-
how many ROIs do you check? Could you just save the ROI to an image if you know you will need it? – KobeJohn Feb 05 '12 at 16:14
2 Answers
If you are working with a bitmap or other format that stores bits in a regular pattern, then yes you can do this by decoding the file yourself and only reading the offsets that you need.
Extracting part of a PNG image
I am not sure, but I think with jpeg, that is not possible since the image is stored as frequency domain information meaning you would need all of the data to produce any one part of the image in the original detail.
Or as I suggested in the comments, you could just save the ROI when you have it in memory if you have a limited number of ROIs and you know which ones you will need later (or even if you don't know which ones if there are not so many).
Which of those sounds like a good approach for you? I did the bmp reading at some point a long time ago, but don't have the code on hand. I could dig up the opencv code if you need that for saving ROI. It's pretty easy though.

- 7,390
- 6
- 41
- 62
We had the same problem and ended up using GDAL (http://www.gdal.org) for loading images and then converting them to IplImage.

- 4,163
- 4
- 31
- 39
-
Grate - I would love to use it if it would help!) Any recomendations on where to look into GDAL?) – myWallJSON Feb 08 '12 at 13:28
-
I wasn't the lead programmer in the project but you can check the link above and study the library a bit – Itay k Feb 12 '12 at 10:07