Recent

Author Topic: Question: Handling large image files  (Read 2344 times)

avra

  • Hero Member
  • *****
  • Posts: 2112
    • Additional info
Re: Question: Handling large image files
« Reply #30 on: December 23, 2020, 01:32:22 pm »
It might be interesting to take a look at this:
https://github.com/libvips/libvips/wiki/Why-is-libvips-quick
That lib has C headers so should not be hard to convert them to Pascal.

This lib has COM object:
http://www.graphicsmagick.org/ImageMagickObject.html
That means that you can easily import it into IDE. For more info read this post: https://forum.lazarus.freepascal.org/index.php/topic,52586.msg388065.html#msg388065

And, of course, you might decide that you want to improve loading speed of some existing pascal tiff lib, or write your own.
« Last Edit: December 23, 2020, 01:34:27 pm by avra »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

Timur Born

  • New Member
  • *
  • Posts: 16
Re: Question: Handling large image files
« Reply #31 on: December 23, 2020, 01:56:11 pm »
Thank you, I will look into it. The last post of the thread you linked earlier refers to the Graphicsmagick library, which utilizes OpenMP. I am currently looking into this, too.

Timur Born

  • New Member
  • *
  • Posts: 16
Re: Question: Handling large image files
« Reply #32 on: December 23, 2020, 02:29:13 pm »
At least the Photoflow implementation of libvips suggests that it is too slow, both for loading and for zooming/scrolling a large image.

- Decompression of PNG images (Deflate) is single-threaded for decompression.

- Decoding after decompression of PNG or of uncompressed TIFF is done multi-threaded, but all threads only utilize about 15% (!) of their respective CPU core. As a result decoding is slow, surely nowhere near the OpenCV based Nomacs, despite the latter only using a single-thread.

- Scrolling and zooming creates new threads for milliseconds of time and the screen is drawn slow enough that you may have to wait seconds for zooming and see new content being build on screen for scrolling (aka blanks being filled gradually).

So for the time being I will concentrate further research on OpenCV and ImageMagick.

avra

  • Hero Member
  • *****
  • Posts: 2112
    • Additional info
Re: Question: Handling large image files
« Reply #33 on: December 24, 2020, 09:48:25 am »
So for the time being I will concentrate further research on OpenCV and ImageMagick.
There is OpenCV Lazarus wrapper here: https://github.com/t-edson/LazarusOpenCV
That is for old OpenCV 2.4 version. OpenCV has deprecated C api with 3.0 and newer versions, and no one has bothered to flatten C++ headers to C for creating a pascal wrapper. If that version is fast enough for your needs then you do not need to search further. If you need newer OpenCV in pascal then prepare for flattening to C and then creating pascal wrappers, or try to use some older SWIG for that.

These can help with creating wrappers for C libraries or with converting some C code to pascal:
https://forum.lazarus.freepascal.org/index.php/topic,50811.0.html
https://wiki.freepascal.org/Creating_bindings_for_C_libraries
https://wiki.freepascal.org/Common_problems_when_converting_C_header_files
https://wiki.freepascal.org/Pascal_for_C_users
https://wiki.freepascal.org/C_to_Pascal

There were several SWIG based attempts to automate usage of C++ libraries in pascal, but although it worked, patches were never integrated into mainstream SWIG:
https://wiki.lazarus.freepascal.org/SWIG
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

Timur Born

  • New Member
  • *
  • Posts: 16
Re: Question: Handling large image files
« Reply #34 on: December 24, 2020, 12:16:09 pm »
Thanks again!

I am also further investigating libvips, as the available application implementations may not be representative of its possibilities. It should be able to load large images completely into memory given the right parameters, by default it uses disc access for images larger than 100 mb, though.

That being said, I am not sure if the extra work needed to use current implementations of these libraries and (re)learning of Pascal are worth the effort over just going the C(++) route then.
« Last Edit: December 24, 2020, 12:39:04 pm by Timur Born »

avra

  • Hero Member
  • *****
  • Posts: 2112
    • Additional info
Re: Question: Handling large image files
« Reply #35 on: December 24, 2020, 02:08:47 pm »
I am not sure if the extra work needed to use current implementations of these libraries and (re)learning of Pascal are worth the effort over just going the C(++) route then.
Quite reasonable from time needed point of view. However if OpenCV 2.4 is good enough, or quick testing of COM lib and ActiveX controls of ImageMagick goes fine, you might end up in pascal train after all.  ;)
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

 

TinyPortal © 2005-2018