Language comparisons: "Lua" - simpler and faster than RevTalk?

viktoras d. viktoras at ekoinf.net
Wed Mar 10 05:04:18 EST 2010


the sad fact is that many languages out there have a simpler mechanism 
(implemented via libraries) to access and manipulate image pixels. 
RevTalk does not have such a library and manipulation of image pixels is 
therefore unfortunately very slow and awkward :-(

A year ago I put a suggestion for an enhancement in the QC for "more 
efficient pixel access in images" #7636.
However its status is still unconfirmed. Maybe I have to change severity 
from enhancement to critical to make this report more noticeable :-)

Viktoras

Wilhelm Sanke wrote:
> A quote from a website: "An increasing number of software developers 
> are making use of the simplicity and power behind employing a Lua 
> script interface".
>
> I came across "Lua" when searching for image-filter algorithms on the 
> web.
>
> "Lua" is being described for example as "an extensible extension 
> language (especially for C-languages)" and is written in C itself - 
> similar here to the Rev engine which is written in C++. Generally - 
> judging on the basis of my limited experience with Lua - I do not 
> think that Lua is simpler than RevTalk, but when it comes to image 
> processing a few features stand out as even more "higher-level", and 
> in that sense "simpler", than RevTalk.
>
> As Lua remains nearer to C, I assume that the execution of Lua scripts 
> will be faster than such written in RevTalk. I do not know whether Lua 
> scripts are compiled at runtime or build time.
>
> A number of image tools integrate Lua in the form of flter plug-ins or 
> for other tasks:
>
> - "Adobe Photoshop Lightroom" uses Lua for its user interface and to 
> create plugins (see the "Lightroom SDK Guide").
>
> - "Gimp", the open-source and cross-platform Photoshop competitor uses 
> "Gluas", a Lua environment plug-in - ("Gluas is a GIMP plug-in 
> providing an environment for testing algorithms for image processing, 
> using the Lua interpreter. The environment contains a simple editor 
> for entering the algorithms.")
>
> - "DogLua" is based on a 'gluas' plugin spec developed initially for 
> GIMP.
>
> Other programs in this category are
>
> - "Dogwaffle",  "Artweaver", "Anim Studio", "TwistedBrush", "TexGen 
> 0.61" ("is designed to meet all your needs of creating textures"), and 
> also a new "Lua Image Processor".--
>
> I want to address here only three aspects of Lua:
>
> 1. Coordinates of pixel positions and its RGB elements
>
> A typical skeleton script in Lua looks like this:
>
>  "for y=0, height-1 do
>    for x=0, width-1 do
>     r,g,b = get_rgb(x,y)
>
> -- do your stuff here, in this case
> -- process the rgb values
>
>      set_rgb (x,y,r,g,b)
>     end
>    progress(y/height)
>   end"
>
> A near equivalent to this in RevTalk would be:
>
> "repeat with i = 0 to theight -1
>   repeat with j = 0 to twidth -1
>    put chartonum(char i * twidth * 4 + j * 4 + 2 of idata) into R
>    put chartonum(char i * twidth * 4 + j * 4 + 3 of idata) into G
>    put chartonum(char i * twidth * 4 + j * 4 + 4 of idata) into B
>
> -- manipulate the RGB values here
>
>    put numtochar(R) into char i * twidth * 4 + j * 4 + 2 of idata
>    put numtochar(G) into char i * twidth * 4 + j * 4 + 3 of idata
>    put numtochar(B) into char i * twidth * 4 + j * 4 + 4 of idata
>  end repeat
> end repeat"
>
> To speed up this Rev skeleton script the computations could  of course 
> be condensed and placed also outside the inner loop, at least partially:
>
> "put twidth * 4 into trow
> repeat with i = 0 to theight -1
>  put i * trow into ti
>   repeat with j = 0 to twidth -1
>    put ti + j * 4 into tij
>    put chartonum(char tij + 2 of idata) into R
>    put chartonum(char tij + 3 of idata) into G
>    put chartonum(char tij + 4 of idata) into B
>
> -- manipulate the RGB values here
>
>    put numtochar(R) into char tij + 2 of idata
>    put numtochar(G) into char tij + 3 of idata
>    put numtochar(B) into char tij + 4 of idata
>
>  end repeat
> end repeat".
>
> It is obvious that Lua needs only the two plain x,y coordinates to 
> determine the position of a pixel and its RGB components. The more 
> complex computations necessary in the Rev script are running 
> internally "under the hood" of Lua - predefined in C, meaning that in 
> this case Lua is using syntax elements of a higher level than Rev.
---



More information about the use-livecode mailing list