Image/Pixel-Color Operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Image/Pixel-Color Operations > ANA. - Imageworks > Color Table Operations >

Image/Pixel-Color Operations

ANA.RemoveSortedColors

Previous Top Next


MiniRobotLanguage (MRL)

 

ANA.RemoveSortedColors

Replace colors that are similar to a given color with a given color in an IR

 

 

Intention

 

This ccommand will replace colors that are sorted in the Col_Srt Colortable by "Number of Pixels".

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_Srt-Color Table that contains all Colors sorted by the Number of Pixels in the Picture.

 

Using this command is in 3 steps:

 

1. Use 
ANA.AnalyzeColor|0|1

to generate a Color-Table which contains all Colors and number of Pixels.

 

2. (optional) Use 

ANA.GetColorCount|0|$$CNT

to get the total number of colors

 

3. Now call the command to remove those colors that contain the most or least number of Pixels.

ANA.RemoveSortedColors|0|40000|$$CNT|&HFFFFFF

 

 

 

Here is a Sample-Script. This Script will mark the Areas of the Picture which contain most of the Information.

 

VAF.$$PIA=?exeloc\Pics\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

$$REP=&HFFFF00

ANA.GetColorCount|0|$$CNT

CAL.$$LES=$$CNT-10000

' Remove Entries and Paint these Pixels white that are Similar to the Background Color

ANA.RemoveSortedColors|0|$$LES|$$CNT|$$REP

ANA.GetColorCount|0|$$CNT

CAL.$$LES=$$CNT-20000

$$REP=&HFF0000

ANA.RemoveSortedColors|0|$$LES|$$CNT|$$REP

DMP.Speed

ANA.Show|0!

ENR.

 

 

clip0155   clip0174

Using this Command you can take a look, which Colors are not used very often in the picture. Or which parts of the picture contain most of the Information.

 

Here is teh Speed-Dump:

clip0175

 

 

 

 

' This Script will mark locations that contain much information (red), and locations that contain less Information (Yellow).

VAF.$$PIA=?exeloc\Pics\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

$$REP=&HFFFF00

ANA.GetColorCount|0|$$CNT

CAL.$$LES=$$CNT-10000

' Remove most often used colors and Paint these Pixels Yellow

ANA.RemoveSortedColors|0|0|30|$$REP

ANA.AnalyzeColor|0|1

ANA.GetColorCount|0|$$CNT

ANA.Show|0!

CAL.$$LES=$$CNT-30000

$$REP=&HFF0000

' Remove seldom colors and Paint these Pixels Red

ANA.RemoveSortedColors|0|$$LES|$$CNT|$$REP

DMP.Speed

ANA.Show|0!

ENR.

 

clip0155   clip0177   clip0176

     

Here is the Speed-Dump for the Script.

It shows large differences depending on the Amount of Colors to replace, while the amount of Pixels does not play a big role.

clip0178

 

 

Syntax

 

ANA.RemoveSortedColors[|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:

 

  ANA.AnalyeColor

    ANA.Reduce_Colors