Ask Your Question
1

Get the image size without actually opening it

asked 2013-01-18 07:55:30 -0600

osmander gravatar image

updated 2013-01-18 08:44:44 -0600

Hello everyone

i am dealing with very big images(>2gb). i am having some memory problems.

so i wonder if there is way to get the image height without loading the images? now i am using cv::imread() and get the width by mat.rows, which is not very convenient for me.

and my second question would be if there is way to open only a portion of images? for this purpose i open the images again with cv::imread() and get the parts with cv::Mat(imageData, lineRange, sampleRange). i want to directly open the specific parts which are define by lineRange and sampleRange( whose are cv::Range).

Thanks

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
3

answered 2013-01-19 07:28:19 -0600

Guanta gravatar image

Under Unix/Linux you can use 'identify image.png', which (should) read just the header information. Maybe you can use it in your program.

edit flag offensive delete link more
2

answered 2013-01-18 08:26:39 -0600

unxnut gravatar image

Typically, the image size information is part of the image header in almost all the formats. So, if you are dealing with a fixed format, say JPEG, you should be able to write a little function that will open the file, read only the header, and close the file. Of course, this will be not a part of OpenCV library but if there is such a function in OpenCV, that will be great.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2013-01-18 07:55:30 -0600

Seen: 5,137 times

Last updated: Jan 21 '13