Plugin development - RGB picture
Plugin development - RGB picture
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
Re: Plugin development - RGB picture
Hello, the documentation for the plugin SDK, is inside the folder "Generic_plugin", file: Plugins.htm. There are instructions about getting the R,G,B color planes using ac_getbuffer(). For example, from the Lazarus example:
callback(ac_getbuffer, pimage, @buffer, pointer(PCGREEN))
just add:
callback(ac_getbuffer, pimage, @bufferR, pointer(PCRED))
callback(ac_getbuffer, pimage, @bufferB, pointer(PCBLUE))
Greetings,
Fabio.
callback(ac_getbuffer, pimage, @buffer, pointer(PCGREEN))
just add:
callback(ac_getbuffer, pimage, @bufferR, pointer(PCRED))
callback(ac_getbuffer, pimage, @bufferB, pointer(PCBLUE))
Greetings,
Fabio.
Re: Plugin development - RGB picture
Hi Fabio,
thanks for the quick answering I will try that.
Regards
Nuno
thanks for the quick answering I will try that.
Regards
Nuno
Re: Plugin development - RGB picture
Hi Nuno, OK, meanwhile a faster script can be obtained using a Formula:
Image.PrepareUndo
f = "vr : If(0.5*(vr+vb)<vg, 0.5*(vr+vb), vg) : vb"
Image.Formula(f)
Image.Update
It will be faster than a script code, but still slower than a real plugin.
The same formula can be used to create a direct command:
Image.PrepareUndo
f = "vr : If(0.5*(vr+vb)<vg, 0.5*(vr+vb), vg) : vb"
Image.Formula(f)
Image.Update
It will be faster than a script code, but still slower than a real plugin.
The same formula can be used to create a direct command:
Re: Plugin development - RGB picture
Wow, that really shows the power of the formula function.
Thanks for sharing. Meawhile the plugin is already fully working. Blazing fast, instant execution
I just need to add some GUI options to control the amount applied.
Again, thanks for your help.
Regards,
Nuno
Thanks for sharing. Meawhile the plugin is already fully working. Blazing fast, instant execution
I just need to add some GUI options to control the amount applied.
Again, thanks for your help.
Regards,
Nuno
Re: Plugin development - RGB picture
Hi Fabio,
continuing the plugin quest I got another problem.
How can I parse the fits header from the sdk in pascal. That would be important because I need to change
the plugin behaviour on mono and color images along another parameters.
I know that this has to do with basic pointer management, but I am having trouble trying to use the AC_READHEADER function. I can get the pheader pointer (nativeint) but I cant get
the null terminated string parsed. Do you have any examples of this? I am sorry to ask but I have no sdk examples to rely on.
Regards
Nuno
continuing the plugin quest I got another problem.
How can I parse the fits header from the sdk in pascal. That would be important because I need to change
the plugin behaviour on mono and color images along another parameters.
I know that this has to do with basic pointer management, but I am having trouble trying to use the AC_READHEADER function. I can get the pheader pointer (nativeint) but I cant get
the null terminated string parsed. Do you have any examples of this? I am sorry to ask but I have no sdk examples to rely on.
Regards
Nuno