<< 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.RemoveIndexColors
Replace colors that are similar to a given color with a given color in an IR
Intention
This ccommand will replace colors that are equal to a given color with another color.
This Command needs the ANA.AnalyzeColor Command to count colors in an IR before it will work. It may also need the "Force-Flag" (P2) to be set.
It will also use the Color-Similarity Table, therefore you will need to use the ANA.Sort_Similar_To|$$COL|$$MSK
Command prior using this command.
This Command will work on the Col_Bgl-Color Table that contains all Colors sorted by the Similarity to the Background-Color.
Using this command is in 5 steps:
1. Use
ANA.AnalyzeColor|0|1
to generate a Color-Table which contains all Colors and number of Pixels.
2. Sort the Color Table with Similarity to the Background Color
' Greenboard-Color, Mask and the color-range that shall be removed must be adjusted per picture
$$COL=&H30FF30
$$MSK=&HFFFFFF
3. (optional) Use
ANA.GetColorCount|0|$$CNT
to get the total number of colors
4. Use
ANA.Sort_Similar_To|$$COL|$$MSK
to sort the Color-Table by Similarity to the given Color
5. Now call the command to remove those colors that are most similar to the given color.
' Remove Entries and Paint these Pixels white that are Similar to the Background Color
ANA.RemoveIndexColors|0|40000|$$CNT|&HFFFFFF
Here is a Sample-Script.
' This Script will remove a green background
' using special sorting functions.
' The Script is fast and will only take few seconds
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
DBP.$$CNT
' 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.RemoveIndexColors|0|40000|$$CNT|&HFFFFFF
ANA.Show|0!
ENR.
Will bring up this Messagebox: that shows that the Color &HFEFEFE is most likely the Background Color. And this color is found 597379 times in the original picture.
With this picture:
Syntax
ANA.RemoveIndexColors[|P1][|P2][|P3]
Parameter Explanation
P1 - Source and Destination Image-Register Number, if omitted 0 is used.
P2 - Color-Table-Start Index - must be lower then the total number of colors in the Color-Table.
P3 - Color-Table-End Index - In most cases this is the number of Entries in the Color-Table as its given by ANA.GetColorCount|0|$$CNT.
If this number is too high it will automatically be cut down to the maximum. If P3<P2 then these two values will be exchanged.
P4 - Color to paint over or -1 to choose Background-Color, choose -2 then you will get an automatic color-Mix between the color
that is replaced and the next color in the color-Table.
The Command will leave a 0/1 on the TOS. If the Operation fails, TOS will show a "0".
Example
-
Remarks
-
Limitations:
While this command is not a slow command it may still take some seconds to execute, depending on how many colors to remove and the picture-Size.
See also: