<< Click to Display Table of Contents >> Navigation: 3. Script Language > Image/Pixel-Color Operations > ANA. - Imageworks > Color Table Operations > Image/Pixel-Color Operations |
MiniRobotLanguage (MRL)
ANA.ReplaceColorD
Replace Color Direct - Replace a given Color with another Color directly in the IR
Intention
This Command will directly replace colors in an IR. It will replace Color P2 with Color P3. In Image-Register P1.
This Command is NOT really an Color-Table Operation, as it does not need the Color-Table.
Instead it will directly Replace Color P2 with Color P3 in Image-Register P1.
If Color P2 is prefixed with an ! then the Command will work in a negative mode, means it will replace the Color if it does NOT Fit to the Color P2.
' ANA.ReplaceColorD
VAF.$$PIA=?exeloc\Pics\Fux.jpg
ANA.Load|0|$$PIA
ANA.Show|0!
ANA.AnalyzeColor|0|1
' Greenboard-Color, Mask and the color-range that shall be removed must be adjusted per picture
$$SRC=&H000000
$$COL=&H30FF30
ANA.ReplaceColorD|0|$$SRC|$$COL
DMP.Speed
ANA.Show|0!
ENR.
In this Script we will replace the Color that has the most Pixels, with white.
VAF.$$PIA=?exeloc\Sarah_BG.png
ANA.Load|0|$$PIA
ANA.Show|0!
ANA.AnalyzeColor|0|1
ANA.GetBGColor|0|$$BGC
ANA.ReplaceColorD|0|$$BGC|&HFFFFFF
DMP.Speed
ANA.Show|0!
ENR.
Will bring up this Messagebox.
With this picture:
Here we enhance the Script a bit to get the Background removed immediately.
VAF.$$PIA=?exeloc\Sarah_BG.png
ANA.Load|0|$$PIA
ANA.Show|0!
ANA.AnalyzeColor|0|1
' Greenboard-Color, Mask and the color-range that shall be removed must be adjusted per picture
$$COL=&H30FF30
$$MSK=&HFFFFFF
ANA.GetColorCount|0|$$CNT
CAL.$$LES=$$CNT-5
' Sort the Color Table with Similarity to the Background Color
ANA.Sort_Similar_To|$$COL|$$MSK
' Remove Entries and Paint these Pixels white that are Similar to the Background Color
ANA.Reduce_Colors|0|$$LES|$$CNT|90|-1|2
ANA.AnalyzeColor|0|1
ANA.GetBgcolor|0|$$BGC
ANA.ReplaceColorD|0|$$BGC|&HFFFFFF
DMP.Speed
ANA.Show|0!
ENR.
Syntax
ANA.ReplaceColorD|P1|[!]P2[|P3]
Parameter Explanation
P1 - Source & Destination Image-Register Number, if omitted 0 is used.
P2 - Color to be replaced with Color in P3.
If Color P2 is prefixed with an ! then the Command will work in a negative mode, means it will replace the Color if it does NOT Fit to the Color P2.
P3 - (opt.) Color that will replace the Color in P2, if omitted &HFFFFFF (White) is used.
The Command will leave a 0/1 on the TOS. If the Operation fails, P2 may be "0".
Example
'***********************************
' ANA.ReplaceColorD-Sample
'***********************************
VAF.$$PIA=?exeloc\Pics\Fux.jpg
ANA.Load|0|$$PIA
ANA.Show|0!
ANA.AnalyzeColor|0|1
' Greenboard-Color, Mask and the color-range that shall be removed must be adjusted per picture
$$SRC=&H000000
$$COL=&H30FF30
ANA.ReplaceColorD|0|$$SRC|$$COL
DMP.Speed
ANA.Show|0!
ENR.
' Below you can see the result of the Operation.
Here is the Speed-Dump for the Operation
Remarks
This Command is really fast and will do its Job in less then a Second.
Limitations:
-
See also: