Very large image resize (> 32000 pixel)

Just starting out? Need help? Post your questions and find answers here.
technopol
User
User
Posts: 27
Joined: Thu Mar 24, 2011 11:00 pm

Very large image resize (> 32000 pixel)

Post 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?
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Very large image resize (> 32000 pixel)

Post by IdeasVacuum »

IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: Very large image resize (> 32000 pixel)

Post 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!

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
technopol
User
User
Posts: 27
Joined: Thu Mar 24, 2011 11:00 pm

Re: Very large image resize (> 32000 pixel)

Post 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.
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: Very large image resize (> 32000 pixel)

Post 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!

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
technopol
User
User
Posts: 27
Joined: Thu Mar 24, 2011 11:00 pm

Re: Very large image resize (> 32000 pixel)

Post 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?
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: Very large image resize (> 32000 pixel)

Post by JHPJHP »

Hi technopol,

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

JHPJHP
Last edited by JHPJHP on Fri Nov 22, 2013 3:44 pm, edited 2 times in total.

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: Very large image resize (> 32000 pixel)

Post 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
Last edited by JHPJHP on Fri Nov 22, 2013 3:48 pm, edited 7 times in total.

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
AAT
Enthusiast
Enthusiast
Posts: 259
Joined: Sun Jun 15, 2008 3:13 am
Location: Russia

Re: Very large image resize (> 32000 pixel)

Post by AAT »

JHPJHP, thank you for your work and examples!
Please, start new "OpenCV" topic in Tricks 'n' Tips.

Regards!
User avatar
Kurzer
Enthusiast
Enthusiast
Posts: 670
Joined: Sun Jun 11, 2006 12:07 am
Location: Near Hamburg

Re: Very large image resize (> 32000 pixel)

Post 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.
PB 6.02 x64, OS: Win 7 Pro x64 & Win 11 x64, Desktopscaling: 125%, CPU: I7 6500, RAM: 16 GB, GPU: Intel Graphics HD 520, User age in 2024: 56y
"Happiness is a pet." | "Never run a changing system!"
technopol
User
User
Posts: 27
Joined: Thu Mar 24, 2011 11:00 pm

Re: Very large image resize (> 32000 pixel)

Post 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:
Post Reply