Technical‎ > ‎

agmod


ag

The ag module provides a set of commands for manipulating colors of 1 or 2 pictures.

There is 4 categorys for the moment, color functions, Layers functions, Filter functions and Other.

This was write in Blitz Basic language as a personal tutorials. 

Most of this functions are absolutly identical to the Shake's one.


You can download the module's source here:

Download: agmod2.rar


 Original picture A
A fish at the Nausicaa aquarium
 Original picture B
Me during a shooting in a Clinic


Color

Color command
Action
agAdd
Add RGBA color to an image
agBrightness
Mltitiply color by a constant value
agClamp
Clamp low and high color of an image
agCompress

Compress low and high color of an image
agContrast
Contrast an image with value and center
agCopy
Copy channels of an image to another channels
agDiv
Divide RGBA color to an image
agGamma
Change the RGBA gamma of an image
agMonochrome
Convert RGB image to Black and White
agMult
Multiply RGBA color to an image
agReorder
Change the order of channels in an image
agSaturation
Change the saturation of an image



 

 

 

 

 

 

 

 

























































Color Space

Color command
Action
agRGBtoYIQ
 
agYIQtoRGB
 



 

 










Layer

Layer command
Action
agIAdd
Add a color of 1 pictures to another
agIDiv
Divide a picture by another
agIMult
Multiply the color of a picture by another picture
agISub
Substract colors of picture by another
agISubA
Absolute substract colors of picture by another
agMax
Find the maximum color between 2 pictures
agMin
Find the minimum color between 2 pictures
agMix
Mix or transparency between 2 pictures
agScreen
Common screen effect between 2 pictures

 

 

 

 

 

 

 


 









































Filter

Filter command
Action
agBlur33
 
agBlur55
 
agSharpen
 
agEdge33
 
agEdge55
 
agEmboss
 
agSobelH
 
agSobelV
 
agMedian
 
agDilate
 
agErode
 

 

 

 

 

 

 






















































Other

Other command
Action
agPlotScanline
Draw a Scanline of a selected picture line











Function reference

agAdd:TPixmap(pixmap:TPixmap, RCol:Float = 1, GCol:Float = 1, BCol:Float = 1, ACol:Float = 1)   Add a color to each channels independently

Returns: A new pixmap object

RCol, GCol, BCol, ACol are the color value to add to Red, Green, Blue, Alpha channels.


agBrightness:TPixmap(pixmap:TPixmap, bright:Float)   Add a color effect brightness on the picture

Returns: A new pixmap object

A value of 0 made the picture Black. A value of 1 made no change.


agClamp:TPixmap(pixmap:TPixmap, Rlo:Float=0, Glo:Float=0, Blo:Float=0, Alo:Float=0, Rhi:Float=1, Ghi:Float=1, Bhi:Float=1, Ahi:Float=1)   Clamp the color value of your picture

Returns: A new pixmap object

Rlo, Glo, Blo, Alo are the low clamp value in Red, Green, Blue, Alpha.
The default value is 0, no change.

Rhi, Ghi, Bhi, Ahi are the high clamp value in Red, Green, Blue, Alpha.
The default value is 1, no change.


agCompress:TPixmap(pixmap:TPixmap, Rlo:Float=0, Glo:Float=0, Blo:Float=0, Alo:Float=0, Rhi:Float=1, Ghi:Float=1, Bhi:Float=1, Ahi:Float=1)   compress the color value of your picture

Returns: A new pixmap object

This function squeezes the image to fit within the Lo and Hi range you set.
Unlike agClamp, the entire image is modified because it is fit between the two points.
Rlo, Glo, Blo, Alo are the low compress values in Red, Green, Blue, Alpha.
The default value is 0, no change.

Rhi, Ghi, Bhi, Ahi are the high compress values in Red, Green, Blue, Alpha.
The default value is 1, no change.


agContrast:TPixmap(pixmap:TPixmap, Contrast:Float, Center:Float = 0.5)   Add Contrast color effect to your picture

Returns: A new pixmap object

Contrast value is the "strongness" of your contrast. A contrast value of 0 made your picture grey(128). A value of 1 is your original picture.
Center: This is the center of the contrast curve. A Lower value means a brighter image.


agDiv:TPixmap(pixmap:TPixmap, RCol:Float = 1, GCol:Float = 1, BCol:Float = 1, ACol:Float = 1)   Divide Each channel by a constant value.

Returns: A new pixmap object

RCol, GCol, BCol, ACol are the value to divide the picture with.
Remember that the value can't be equal to 0.


agGamma:TPixmap(pixmap:TPixmap, GamR:Float = 1, GamG:Float=1, GamB:Float=1, GamA:Float=1)   Add Gamma color effect to your picture

Returns: A new pixmap object

You can change independently the Gamma of each channel(Red or Green or Blue)
A gamma value of 0 made your channel black.
A value of 1 is your original channel.


agMonochrome:TPixmap(pixmap:TPixmap)   Convert RGB picture in Black and White

agMult:TPixmap(pixmap:TPixmap, RCol:Float = 1, GCol:Float = 1, BCol:Float = 1, ACol:Float = 1)   Multiply each channel of your picture by a value

Returns: A new pixmap object

This function multiplies RCol, GCol, BCol, ACol by a value correponding to Red, Green, Blue, Alpha
If you want to have the same increase to Red, Green, Blue and Alpha channels, use agBrightness


agReorder:TPixmap(pixmap:TPixmap, Order:String = "rgba")   The Reorder operator lets you shuffle channels.

Returns: A new pixmap object

The channels are by default "rgba", but if you want to switch for example the Red and the Blue channels, lets write "bgra"."
Or, if you want to see only the Green channel, just type "ggga"


agSaturation:TPixmap(pixmap:TPixmap, Sat:Float = 1)   Add Saturation color effect to your picture

Returns: A new pixmap object


A saturation value of 0 made your picture black and white. See agMonochrome.


agRGBtoYIQ:TPixmap(pixmap:TPixmap)   Convert RGB color space in YIQ color space.

Returns: A new pixmap object


agYIQtoRGB:TPixmap(pixmap:TPixmap)   Convert YIQ color space in RGB color space.

Returns: A new pixmap object


agCopy:TPixmap(foreground:TPixmap, background:TPixmap, clipMode:Int = 1, channel:String)   Copy channels from 2 pictures

Returns: A new pixmap object

This function is a Copy Layer function.
This function copies selected channels from Image B to Image A, replacing them entirely.
clipMode is to crop the result on the background image size or on the foreground image size.
Default is on the background image (clipMode = 1)
channel is to define witch channel will be copy from image B to image A.
For example, if you want to copy the Red and Blue channels from the image B to the image A, just type "rb"


agIAdd:TPixmap(foreground:TPixmap, background:TPixmap, clipMode:Int = 1, Percent:Float = 100)   Add 2 pictures

Returns: A new pixmap object

This function is a additive Layer function.
This image math function adds one image to another. The second image's strength can also be raised up and down with the percent parameter.
clipMode is to crop the result on the background image size or on the foreground image size.
Default is on the background image (clipMode = 1)
percent is the intensity of the effect. 100% = full additive, 0% = only foreground.

Example:

Graphics 850,850,0,0
image1:TPixmap = LoadPixmap("c:\your picture A.bmp")
image2:TPixmap = LoadPixmap("c:\your picture B.bmp")

image1 = agIAdd(image1, image2, 1, 100)


DrawPixmap(image1,0,0)
Flip
WaitKey()

agIDiv:TPixmap(foreground:TPixmap, background:TPixmap, clipMode:Int = 1)   This image math function divides one image by another.

Returns: A new pixmap object


clipMode is to crop the result on the background image size or on the foreground image size.
Default is on the background image (clipMode = 1)


agIMult:TPixmap(foreground:TPixmap, background:TPixmap, clipMode:Int = 1)   This image math function multiplies one image by another.

Returns: A new pixmap object


clipMode is to crop the result on the background image size or on the foreground image size.
Default is on the background image (clipMode = 1)


agISub:TPixmap(foreground:TPixmap, background:TPixmap, clipMode:Int = 1)   This image math function subtracts one image from another.

Returns: A new pixmap object


clipMode is to crop the result on the background image size or on the foreground image size.
Default is on the background image (clipMode = 1)


agISubA:TPixmap(foreground:TPixmap, background:TPixmap, clipMode:Int = 1)   This image math function subtracts one image from another.

Returns: A new pixmap object

This is identical to ISub, except that it takes the absolute value of the result.
This is to see if similar images are different by subtracting one from another.
If the second image is brighter, ISub won't reveal anything, but ISubA will (ie, .5 - .8 = -.3, absolute value of -.3 = .3).

clipMode is to crop the result on the background image size or on the foreground image size.
Default is on the background image (clipMode = 1)


agMax:TPixmap(foreground:TPixmap, background:TPixmap, clipMode:Int = 1, percent:Float)   Compares two images and takes the pixel with the higher value.

Returns: A new pixmap object


clipMode is to crop the result on the background image size or on the foreground image size.
Default is on the background image (clipMode = 1)
percent is the intensity of the effect.


agMin:TPixmap(foreground:TPixmap, background:TPixmap, clipMode:Int = 1, percent:Float = 100)   Compares two images and takes the pixel with the Lower value.

Returns: A new pixmap object


clipMode is to crop the result on the background image size or on the foreground image size.
Default is on the background image (clipMode = 1)
percent is the intensity of the effect.


agMix:TPixmap(foreground:TPixmap, background:TPixmap, clipMode:Int = 1, Percent:Float = 100, channels:String= "rgba")   Mix 2 pictures (or transparency)

Returns: A new pixmap object

This function is a mix Layer function.
This mixes two images together according to a percentage.
clipMode is to crop the result on the background image size or on the foreground image size.
Default is on the background image (clipMode = 1)
percent is the intensity of the effect. 0% = foreground, 50% = mix, 100% = background
channels: Which channels to be mixed. Default is "rgba".

Example:

Graphics 850,850,0,0
image1:TPixmap = LoadPixmap("c:\your picture A.bmp")
image2:TPixmap = LoadPixmap("c:\your picture B.bmp")

image1 = agMix(image1, image2, 1, 50, "rg")


DrawPixmap(image1,0,0)
Flip
WaitKey()

agScreen:TPixmap(foreground:TPixmap, background:TPixmap, clipMode:Int = 1)   Screen effect on 2 pictures

Returns: A new pixmap object

This mimics the effect of exposing two film negatives together.
Technically, it inverts both layers, multiplies the two together, and inverts the result back.
It is particularly handy for doing reflections and luminescent elements, as it preserves the highlights.

clipMode is to crop the result on the background image size or on the foreground image size.
Default is on the background image (clipMode = 1)


agBlur33:TPixmap(pixmap:TPixmap)   Blur filter 3*3 kernel on a picture

Returns: A new pixmap object


agBlur55:TPixmap(pixmap:TPixmap)   Blur filter 5*5 kernel on a picture

Returns: A new pixmap object


agSharpen:TPixmap(pixmap:TPixmap)   Sharpen filter 3*3 kernel on a picture

Returns: A new pixmap object


agEdge33:TPixmap(pixmap:TPixmap)   Edge filter 3*3 kernel on a picture

Returns: A new pixmap object


agEdge55:TPixmap(pixmap:TPixmap)   Edge filter 5*5 kernel on a picture

Returns: A new pixmap object


agEmboss:TPixmap(pixmap:TPixmap, center:int = 128)   Emboss filter on a picture

Returns: A new pixmap object


agMedian:TPixmap(pixmap:TPixmap, threshold:float)   Median 3*3 filter on a picture

Returns: A new pixmap object

It is good for the removal of individual dots and noise.
threshold the intensity of the effect


agDilate:TPixmap(pixmap:TPixmap, xPixels:int = 1, yPixels:int = 1)   Dilate the pixels of a picture

Returns: A new pixmap object

xPixels and yPixels are the size of the kernel.


agErode:TPixmap(pixmap:TPixmap, xPixels:int = 1, yPixels:int = 1)   Erode the pixels of a picture

Returns: A new pixmap object

xPixels and yPixels are the size of the kernel.


agSobelH:TPixmap(pixmap:TPixmap)   Horizontal Sobel edge filter 3*3 kernel on a picture

Returns: A new pixmap object


agSobelV:TPixmap(pixmap:TPixmap)   Vertical Sobel edge filter 3*3 kernel on a picture

Returns: A new pixmap object


agPlotScanline:TPixmap(pixmap:TPixmap, line:Int=0)   Plot Scanline is a tool color function.

Returns: A new pixmap object of 256 pixel height


This analysis tool examines a line of an image and graphs the intensity of each channel per x position.
It is extremely helpful in determining what a color correction function is doing.
Although you can attach it to any image to analyze it, you often attach it to a horizontal Ramp to observe a color corrections behavior.


Module Information

Module pub.ag
Version 1.05
Author Lempereur Bertrand
License Public Domain
Credit Advanced pixmap graphic functions
CustomAttr See!

Comments