<< Click to Display Table of Contents >> Navigation: 3. Script Language > Image/Pixel-Color Operations > ANA. - Imageworks > Pixel-Operation > Image/Pixel-Color Operations |
MiniRobotLanguage (MRL)
ANA.SetPixelRGB
Set the Color of a Single Pixel from an Image-Register (IR) using the RGB-Values
Intention
This command will change the color of a Single Pixel in an IR. Instead of specifying the Color-Value as one Number, you can specify the R,G and B-Part here separately.
Use this command together with other Commands like ANA.GetPixelRGB.
For Speed-Reasons, this command will never return anything on the TOS.
1. Doing Color-Changes/Corrections
In this Sample we will change the Colors in the Picture.
For this we will read the Pixel, check if its mostly Green, and in that case replace it with the colors taken from another Picture.
Due to the use of a nested Loop going "Line by Line" through all Pixels, it is recommended to start the script in the Editor using "Freerun Mode".
Even then the Script still may use several Minutes to finish. You will see in the Editor-Debug-Window the current Line and the last line.
You will not see the Robot Painting unless the Show command is been called which leads to an Update in the Show-Window.
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
FOR.$$YPO|1|$$YSZ
DBP.$$YPO/$$YSZ
FOR.$$XPO|1|$$XSZ
ANA.GetPixelRGB|0|$$XPO|$$YPO|$$RED|$$GRN|$$BLU
CAL.$$RED=$$RED*1.1-70
CAL.$$GRN=$$GRN*1.1-70
CAL.$$BLUE=$$BLU*1.1-70
ANA.SetPixelRGB|1|$$XPO|$$YPO|$$RED|$$GRN|$$BLU
NEX.
NEX.
ANA.Save|1|$$PIC
CAL.$$TIM=#time#-$$TIM
DBP.Used Time in Seconds: $$TIM
DMP.1
ANA.Show|1!
ENR.
->
This is the Original picture. . The is the picture with the colors changed.
The Speed-dump shows that the Robot can do such correction very fast, yet simple changes on the whole picture can be done faster using other commands.
2. Picture Mixing
In this Sample we will mix 2 Pictures depending on the relation between Blue and Red.
In the SPR you can use virtually unlimited Graphics Sources to be combined.
.
VAN.$$TIM=#time#
VAF.$$PIA=?pattern\SarahB_640.jpg
VAF.$$PIC=?pattern\SarahC_640.jpg
ANA.Load|0|$$PIA
ANA.Copy|0|1
ANA.Grey|1
ANA.GetRes|0|$$XSZ|$$YSZ
ANA.New|1|$$XSZ|$$YSZ
FOR.$$YPO|1|$$YSZ
DBP.$$YPO/$$YSZ
FOR.$$XPO|1|$$XSZ
ANA.GetPixelRGB|0|$$XPO|$$YPO|$$RED|$$GRN|$$BLU
IVV.$$BLU>$$RES
ANA.GetPixelRGB|1|$$XPO|$$YPO|$$RED|$$GRN|$$BLU
EIF.
ANA.SetPixelRGB|1|$$XPO|$$YPO|$$RED|$$GRN|$$BLU
NEX.
NEX.
ANA.Save|1|$$PIC
CAL.$$TIM=#time#-$$TIM
DBP.Used Time in Seconds: $$TIM
DMP.1
ANA.Show|1!
ENR.
->->
The Script used ~99 Seconds to complete process the picture. If you change the IVV. to NVV. Command, the result will be the third picture or when using $$BLU and $$GRN the fourth picture.
Here is the Speed-Dump:
Syntax
ANA.SetPixelRGB[|P1][|P2][|P3][|P4][|P5][|P6]
Parameter Explanation
P1 - Target Image-Register number
P2 - X1 - Upper Left Coordinat X-Value
P3 - Y1 - Upper Left Coordinat Y-Value
P4 - Variable for Color-Value RED.
P5 - Variable for Color-Value GREEN.
P6 - Variable for Color-Value BLUE.
The color values will always be in the range between 0-255. This is Hexadacimal: 0 - &HFF.
Example
See above.
Remarks
The ANA.SetPixelColor is optimized for Speed. It will use only about 200 to 336 Ticks. Therefore the Robot could write more then 47000 Pixels per Second. In EXE Mode its even faster then in Free-Run Mode (from Editor).
Limitations:
-
See also:
•