Plugin development - RGB picture
Posted: 19 Jul 2022, 11:45
Hi!
I am been trying to develop plugins for some functions I miss on AstroArt (SCNR, ArcSinStretch, HyperBolicStretch and others).
I know there is already a "Attenuate one color" function but the SCNR script port I made is more effective (neutral) removing the color cast
even messing around with the other options (Strength, Level and Range). Let's use it as an example:
-----------------------------------------------------------------------------------------------------------------------------------
Image.PrepareUndo
REM Average Neutral Protection
REM m = 0.5×(R + B)
REM G = Min( G, m )
x1 = 0
y1 = 0
x2 = Image.Width
y2 = Image.Height
for y = y1 to y2
for x = x1 to x2
r = Image.GetPixelR(x,y)
g = Image.GetPixelG(x,y)
b = Image.GetPixelB(x,y)
m = 0.5 * (r + b)
newg = min (g, m)
Image.SetPixel(x, y, r, newg, b)
next x
next y
Image.Update
function Min (value1,value2)
if value1 < value2 then return value1 else return value2
end function
-----------------------------------------------------------------------------------------------------------------------------------
The thing is that the script is slow (20s to execute on i3 10100F/32G ram/NVME) so I would like to convert it to a plugin so it can execute faster
and add some GUI elements. I have already looked at the SDK sources (I am using lazarus) and compiled a 64bit version of the demo plugin with
sucess and use it in AA8.
The problem is that based on the demo code, I can only work with the ac_getbuffer function wich only gets one plane of image. Is there any other
function that works like the script and gives you the 3 channel RGB image instead of only one plane? Maybe ac_getimage (selection, nil, nil) ?
I am bit lost here even looking at the information provided. Are there any detailed examples of the SDK funcions?
So resuming, how can I convert this script to a plugin using the Lazarus code of the SDK?
Thank you and Regards
Nuno Carregueira
I am been trying to develop plugins for some functions I miss on AstroArt (SCNR, ArcSinStretch, HyperBolicStretch and others).
I know there is already a "Attenuate one color" function but the SCNR script port I made is more effective (neutral) removing the color cast
even messing around with the other options (Strength, Level and Range). Let's use it as an example:
-----------------------------------------------------------------------------------------------------------------------------------
Image.PrepareUndo
REM Average Neutral Protection
REM m = 0.5×(R + B)
REM G = Min( G, m )
x1 = 0
y1 = 0
x2 = Image.Width
y2 = Image.Height
for y = y1 to y2
for x = x1 to x2
r = Image.GetPixelR(x,y)
g = Image.GetPixelG(x,y)
b = Image.GetPixelB(x,y)
m = 0.5 * (r + b)
newg = min (g, m)
Image.SetPixel(x, y, r, newg, b)
next x
next y
Image.Update
function Min (value1,value2)
if value1 < value2 then return value1 else return value2
end function
-----------------------------------------------------------------------------------------------------------------------------------
The thing is that the script is slow (20s to execute on i3 10100F/32G ram/NVME) so I would like to convert it to a plugin so it can execute faster
and add some GUI elements. I have already looked at the SDK sources (I am using lazarus) and compiled a 64bit version of the demo plugin with
sucess and use it in AA8.
The problem is that based on the demo code, I can only work with the ac_getbuffer function wich only gets one plane of image. Is there any other
function that works like the script and gives you the 3 channel RGB image instead of only one plane? Maybe ac_getimage (selection, nil, nil) ?
I am bit lost here even looking at the information provided. Are there any detailed examples of the SDK funcions?
So resuming, how can I convert this script to a plugin using the Lazarus code of the SDK?
Thank you and Regards
Nuno Carregueira