<< Click to Display Table of Contents >> Navigation: 3. Script Language > Image/Pixel-Color Operations > ANA. - Imageworks > Color-Calculation > Image/Pixel-Color Operations |
MiniRobotLanguage (MRL)
ANA.Color_Diff_RGB and other ...
Split the a specified Color-Value into R,G and B
Intention
These commands will take 2 Color-Values and calculate the Color-Difference between these values. Internally the Color-Difference is the Sum of the Differences between the R,G and B Parts of both values.
The smaller the Color Difference, the the more equal the colors should be.
Generally most Information you can get using:
ANA.Color_Diff_RGB|&HF0F1F2|&HFFAADD|$$RED|$$GRN|$$BLUE
Here you will get all 3 Color-Differences between the 2 given colors, in 3 Variables.
Then you can calculate yourself whatever you are interested in.
The other Commands try to do some Speed-Up for special purpose Operations.
' This Command will return only the largest Color-Distance of the 3 values: Red, Green and Blue
ANA.Color_Diff_Max|&HF0F1F2|&HFFAADD|$$MAX
' This Command will return only the smallest Color-Distance of the 3 values: Red, Green and Blue
ANA.Color_Diff_Min|&HF0F1F2|&HFFAADD|$$MIN
' This Command will return only the RED Color-Distance between the 2 Color-Values
ANA.Color_Diff_R|&HF0F1F2|&HFFAADD|$$RED
' This Command will return only the GREEN Color-Distance between the 2 Color-Values
ANA.Color_Diff_G|&HF0F1F2|&HFFAADD|$$GRN
' This Command will return only the BLUE Color-Distance between the 2 Color-Values
ANA.Color_Diff_B|&HF0F1F2|&HFFAADD|$$BLU
1. Sample for ANA.Color_Diff_Max
Normally this Command can be used to find structures in GUI's, for example Letters. Here we can use it for some Artwork.
We will find Borders and paint then red.
VAN.$$TIM=#time#
VAF.$$PIA=?pattern\SarahB_640.jpg
VAF.$$PIC=?pattern\SarahC_640.jpg
ANA.Load|0|$$PIA
ANA.GetRes|0|$$XSZ|$$YSZ
ANA.New|2|$$XSZ|$$YSZ
$$COL=&H808080
FOR.$$YPO|1|$$YSZ
DBP.$$YPO/$$YSZ
FOR.$$XPO|1|$$XSZ
ANA.GetPixelColor|0|$$XPO|$$YPO|$$COL
ANA.GetPixelRGB|0|$$XPO|$$YPO|$$RED|$$GRN|$$BLU
ANA.Color_Diff_Max|$$LAS|$$COL|$$RES
CAL.$$RES=$$RES*6
ANA.SetPixelRGB|2|$$XPO|$$YPO|$$RES|$$GRN|$$BLU
$$LAS=$$COL
NEX.
NEX.
ANA.Save|2|$$PIC
CAL.$$TIM=#time#-$$TIM
DBP.Used Time in Seconds: $$TIM
DMP.1
ANA.Show|2!
MBX.Used Time in Seconds: $$TIM
ENR.
And then Paint the Picture.
In the SPR you can use virtually unlimited Graphics Sources to be combined.
->
It Needs about 250 Seconds to find the borders and paint them red.
This is the Speed-Dump of the Operation.
2. Multi-Step Picture Processing
Here we have a 2-Pass Picture Processing. As the SPR can use multiple IR's, any intelligent sort of Picture Processing can be done in as man steps as needed.
In the first step we find the borders like in the picture above. In the second step we paint the borders larger.
VAN.$$TIM=#time#
VAF.$$PIA=?pattern\SarahB_640.jpg
VAF.$$PIC=?pattern\SarahC_640.jpg
ANA.Load|0|$$PIA
ANA.GetRes|0|$$XSZ|$$YSZ
ANA.New|1|$$XSZ|$$YSZ
ANA.New|2|$$XSZ|$$YSZ
$$COL=&H808080
FOR.$$YPO|1|$$YSZ
DBP.$$YPO/$$YSZ
FOR.$$XPO|1|$$XSZ
ANA.GetPixelColor|0|$$XPO|$$YPO|$$COL
ANA.GetPixelRGB|0|$$XPO|$$YPO|$$RED|$$GRN|$$BLU
ANA.Color_Diff_Max|$$LAS|$$COL|$$RES
CAL.$$RES=$$RES*8
ANA.SetPixelRGB|2|$$XPO|$$YPO|$$RES|$$GRN|$$BLU
$$LAS=$$COL
NEX.
NEX.
FOR.$$YPO|1|$$YSZ
DBP.$$YPO/$$YSZ
FOR.$$XPO|1|$$XSZ
ANA.GetPixelColor|0|$$XPO|$$YPO|$$COL
ANA.GetPixelRGB|2|$$XPO|$$YPO|$$RED|$$GRN|$$BLU
CAL.$$ERG=($$RED>$$BLU)+($$RED>$$GRN)+($$RED>&H80)+($$GRN<&H40)+($$BLU<&H40)
IVV.$$ERG>3
'ANA.SetPixelColor|1|$$XPO|$$YPO|&HFFFF00
ANA.DrawBox|1|$$XPO|$$YPO|($$XPO+2)|($$YPO+2)|&HFF0000
ELS.
ANA.SetPixelColor|1|$$XPO|$$YPO|$$COL
EIF.
NEX.
NEX.
ANA.Save|1|$$PIC
CAL.$$TIM=#time#-$$TIM
DBP.Used Time in Seconds: $$TIM
DMP.1
ANA.Show|1!
MBX.Used Time in Seconds: $$TIM
ENR.
->->
In EXE-Mode this Script needed 247 Seconds thats roughly 4 minutes.
The Speed-Dump of the Script shows that the ANA.Color_Diff_Max uses only about 200 Ticks execution Time.
Syntax
ANA.Color_Diff_RGB|P1|P2[|P3][|P4][|P5]
Parameter Explanation
P2 - Color A - Value, Color-Value 24-Bit. Example: &HFF00FF
P2 - Color B - Value, Color-Value 24-Bit. Example: &HFF00FF
P3 - Variable for Color-Value for Red, for resulting Color Value (24-Bit, Format in Hexadezimal: &HFFFFFF=RR GG BB). If missing the value is been placed on TOS.
P4 - Variable for Color-Value for Green, for resulting Color Value (24-Bit, Format in Hexadezimal: &HFFFFFF=RR GG BB). If missing the value is been placed on TOS.
P5 - Variable for Color-Value for Blue, for resulting Color Value (24-Bit, Format in Hexadezimal: &HFFFFFF=RR GG BB). If missing the value is been placed on TOS.
ANA.Color_Diff_Max|P1|P2[|P3]
ANA.Color_Diff_Min|P1|P2[|P3]
ANA.Color_Diff_R|P1|P2[|P3]
ANA.Color_Diff_G|P1|P2[|P3]
ANA.Color_Diff_B|P1|P2[|P3]
Parameter Explanation
P2 - Color A - Value, Color-Value 24-Bit. Example: &HFF00FF
P2 - Color B - Value, Color-Value 24-Bit. Example: &HFF0000
P3 - Variable for result Color-Value (8-Bit, Format in Hexadezimal: 00-&HFF). If missing the value is been placed on TOS.
Example
See above.
Remarks
The ANA.Color_Diff-Commands are optimized for Speed. It will use only about 300 Ticks. Therefore the Robot could execute it more then 53000 times per Second.
Limitations:
-
See also:
•