Recent

Author Topic: Performance on acces in read/write pixels on canvas under windows and tux  (Read 6330 times)

leneant

  • New Member
  • *
  • Posts: 11
Hello,
I'm french and i create a image process software.
I'm using lazarus 1.2.0 under windows and linux.

To translate pix from canvas into my own memory format i read canvas pixels of tbitmap object.

For the same pix under windows the process take less than 7 seconds. But under linux the same process takes more than 3 minuts. Linux target compiled.

But if i run the windows target compiled under wine the process take less than 7 seconds.

Could you help me to resolve the performances diferences between linux and windows ?

Web site : http://traitement-d-images-tim.webnode.fr/
Sourceforge : http://sourceforge.net/projects/traitementdimagestim/

Is there some one interests to help me and participate to develop tim with me under linux, windows and mac ?

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Quote
To translate pix from canvas into my own memory format i read canvas pixels of tbitmap object.
Do you loop over Canvas.Pixels property? If yes, then change your code. It's a damn slow operation. Read "Developing with Graphics" wiki article for an insight. I don't know what makes it faster on windows, logically the difference should be similar (actually, linux should be faster. otherwise, something odd must be happening).

circular

  • Hero Member
  • *****
  • Posts: 4196
    • Personal webpage
In your program, you are using bytes to store red/green/blue values. That is what I have done in my library BGRABitmap, so you may not have to change much of your code to use it. See for example this tutorial:
http://wiki.freepascal.org/BGRABitmap_tutorial_4

We could also work together to improve LazPaint.  :)
Conscience is the debugger of the mind

x2nie

  • Hero Member
  • *****
  • Posts: 515
  • Impossible=I don't know the way
    • impossible is nothing - www.x2nie.com
Hi


I just visited your site. Wow! it's amazing program.
It refine the picture in better appearance.


Years ago, I found a software that has similar ability according your "TIM", that named "SmartDeBlur".
But, Deblur can be used to restore very-blurred (defocused) picture into understandable by our eyes in unbelievable level of restoration !


I can't modify Deblur, since it was (if I were not wrong) written in Java.
Oh yeah, I am glad your code is written in Pascal.


I think I am interesting, I will get a try this weekend.
---------------------------------------


Now, about the bitmap:
I recomended to use TBitmap32 for manipulating bitmap.
It has MMX, SSE,SSE2, etc. instructionset support.
It always uses 32bit (R,G,B,A), don't know if we can use for your software requirements (R,G,B,L)
It has Windows, Linux, Mac (Cocoa & Carbon) supported, via it's backends (QT, GTK, etc)


I think, by using TBitmap32 would reduce many time of image-processing time.






PS:
 Tbitmap32 site:
  * http://graphics32.org/wiki/
  * http://graphics32.org/news/newsgroups.php?group=graphics32.general


 SmartDeblur site:
   * http://yuzhikov.com/projects.html
   * https://github.com/Y-Vladimir/SmartDeblur
« Last Edit: April 24, 2014, 07:23:40 pm by x2nie »
When you were logged in, you can see attachments.
Lazarus Github @ UbuntuCinnamon-v22.04.1 + LinuxMintDebianEdition5

x2nie

  • Hero Member
  • *****
  • Posts: 515
  • Impossible=I don't know the way
    • impossible is nothing - www.x2nie.com
Quote
To translate pix from canvas into my own memory format i read canvas pixels of tbitmap object.
Do you loop over Canvas.Pixels property? If yes, then change your code. It's a damn slow operation.


I've experienced (knowing) with Tbitmap."PIXEL".
In Delphi, we can avoid "damn slow operation" by call TBitmap.Lock / Canvas.Lock which is used to detach the screen update while the pixel updated.
This way is usually used in game, while a frame being painted.
In the end, we need to call the opposite, which is Unlock to make the bitmap/canvas to back ready to be copied to screen.


Linus Trovalds said: "Speaking is easy, show me the code."
The code is in "LocasAnt" game code here:
* http://www.denysalmaral.com/p/free-downloads.html
When you were logged in, you can see attachments.
Lazarus Github @ UbuntuCinnamon-v22.04.1 + LinuxMintDebianEdition5

engkin

  • Hero Member
  • *****
  • Posts: 3112
SmartDeblur site:
   * http://yuzhikov.com/projects.html
   * https://github.com/Y-Vladimir/SmartDeblur
Thanks for sharing this. It's impressive.

we can avoid "damn slow operation" by call TBitmap.Lock / Canvas.Lock which is used to detach the screen update while the pixel updated.
I don't think it works faster on other widget sets like GTK2 on Linux.

leneant

  • New Member
  • *
  • Posts: 11
Thanks for all your answers. I will watch them. I think i will be able to push a new version on sourceforge this week-end or next week.
Yesterday i looked a page that compare many ways to access pixels of a bitmap. In first i think i will try to make direct access of bitmap memory with rawimage. I had already make that but it ran well under windows but not under linux. Now i understand why. I need to make specif code for windows and linux. On windows pixels are coded on three bytes but on foor under linux. Thats why my previous try didn't run well under linux.
After that for new major version i will try others libraries described in yours posts.
Thank you for your help.
I'll be back soon with my experience with direct acces of bitmap memory.

leneant

  • New Member
  • *
  • Posts: 11
I used direct memory access in place of pixels[x,y] from canvas
Its much better and i can use Tim in virtualbox :-)

Linux exe : http://sourceforge.net/projects/traitementdimagestim/files/Experimental/TIm/x86/Linux-x86-Tim-V0.65.zip/download

sourceforge project : https://sourceforge.net/projects/traitementdimagestim/files/

Web page (in french) : http://traitement-d-images-tim.webnode.fr/

x2nie : if you are interested you can contact me with the e-mail posted on the web site.

For all : Thank you for your help.  :D

 

TinyPortal © 2005-2018