Page 1 of 1

Very large image resize (> 32000 pixel)

Posted: Wed Nov 20, 2013 12:24 pm
by technopol
I need to perform fast smooth resizing on images much wider than 32000 pixels (actual ResizeImage() limit). Is there an easy way or should I write my own assembly routine?

Re: Very large image resize (> 32000 pixel)

Posted: Wed Nov 20, 2013 6:18 pm
by IdeasVacuum

Re: Very large image resize (> 32000 pixel)

Posted: Wed Nov 20, 2013 10:54 pm
by JHPJHP
Hi technopol,

I've been working on an OpenCV wrapper, and one of the available functions is cvResize (image)... I just added a new example with this function included, testing an image size of 16000 x 16000 (the largest I could find), it seemed to work fairly quickly; not sure if it will meet your requirements though.

Also the wrapper requires third party DLL's which may not be an option for you, but if you're still interested I will send you a link.

Cheers!

Re: Very large image resize (> 32000 pixel)

Posted: Thu Nov 21, 2013 6:51 am
by technopol
Thanks IdeasVacuum;
now I understand it is just a manner of old 32-bit code not yet converted to 64-bit.

Just too bad the size limiting is done only for each dimension separately, instead of limiting the size of the image based on actual memory size used. Since the image I need to resize is very large in one dimension but very short in the other, it would surely fit very easily inside a 32-bit world.

JHPJHP,
a wrapper for OpenCV is more than welcome! I was about to use it in the same application and a simple way to address their libraries would accelerate my job a lot. Reading their examples in C and VB gives me headaches; even though I've already done VB.

Have you done, or planed to wrap the image acquisition part of OpenCV?

Tell me where I can buy this jewel.

Re: Very large image resize (> 32000 pixel)

Posted: Fri Nov 22, 2013 1:53 am
by JHPJHP
Reading their examples in C and VB gives me headaches
- you're telling me... it took awhile to figure out some of the syntax as it didn't always match the documentation

Let me know if you have any questions; feedback is appreciated.
- 18 examples (cv_* uses OpenCV window - includes context menu, pb_* embedded OpenCV in PureBasic window)
- x86 binaries included (OpenCV & M$ Runtime)
- should be working on Vista and above (tested: Windows 7 64bit)

Update
- added cvResize to most of the examples because very large images caused an application crash

Cheers!

Re: Very large image resize (> 32000 pixel)

Posted: Fri Nov 22, 2013 3:43 am
by technopol
I got the files, thanks a lot!

My application is currently written in 64-bit, on a Windows 8 machine; but I don't think it might cause problem, right?

Re: Very large image resize (> 32000 pixel)

Posted: Fri Nov 22, 2013 4:04 am
by JHPJHP
Hi technopol,

If you're using the PureBasic 64-bit IDE, then the 64-bit binaries from OpenCV are required.

JHPJHP

Re: Very large image resize (> 32000 pixel)

Posted: Fri Nov 22, 2013 8:13 am
by JHPJHP
Updated the package (now located in the Tricks 'n' Tips forum)
- includes the latest binaries from OpenCV v2.4.7 (x86 / x64)
-- still some issues to work out with x64
- http://www.purebasic.fr/english/viewtop ... 40&t=57457

JHPJHP

Re: Very large image resize (> 32000 pixel)

Posted: Fri Nov 22, 2013 1:03 pm
by AAT
JHPJHP, thank you for your work and examples!
Please, start new "OpenCV" topic in Tricks 'n' Tips.

Regards!

Re: Very large image resize (> 32000 pixel)

Posted: Fri Nov 22, 2013 1:36 pm
by Kurzer
I'm not very deeply involved in this topic, but just an idea...

Why not breaking down the huge image into several tiles (e.g. 32Kpixel x 32Kpixel), scaling the tiles down seperately and then put them together to a rezised destination image?

Maybe using overlaping bounds to prevent artefacts at the edges of the tiles.

Re: Very large image resize (> 32000 pixel)

Posted: Tue Nov 26, 2013 4:33 am
by technopol
All the routines I have tested doesn't provide the speed we need for our application (processing a few hundred GB at one point of the process, as fast as possible, so production process isn't too slow). I'll have to build a very optimized scaling routine using SIMD and process 10 RGB (or 32 grayscale) pixels at once.

The image processing I'm designing is new and its possible to greatly optimize the process for this specific application. If not fast enough, I'll have to go with GPU processing. Or I might be able to fit all data and code inside this thread's available L2 cache and/or split the process into parallel threads to achieve good production speed.

ASM is my world, I should have started there at first. :wink: