<< Click to Display Table of Contents >> Navigation: 3. Script Language > Image/Pixel-Color Operations > ANA. - Imageworks > Pixel-Operation > ANA.GetPixelColor_4S |
MiniRobotLanguage (MRL)
ANA.GetPixelColor_4S
Get the Color of the 4 direct neighbors of a Single Pixel from an Image-Register (IR)
Intention
This command will read the colors of 4 Pixels that are direct neighbor to a given Pixel in an IR.
Together with other Commands like ANA.SetPixelColor, It can be used to clean up Images and remove noise.
This command replaces 4 separate GetPixelColor-Commands (plus needed calculations) and is therefore an Option to speed
up Scripts. If a Pixel has no neighbor (Border Pixels) the result of that Color is -1.
The Colors of these Pixels are returned in Variables in P4 to P7.
With this command, the returned value is always the 24-bit color of the Pixel unless there is no such Pixel.
If you specify a Pixel that is at a border and has no Pixel to the left/right etc. then the returned value will be -1.
1. Clean up a digitized Picture, remove noise using an SPR-Script
In this Sample we will remove the noise from a picture using the SPR.
For this we will read the Pixel, check if it has only white neighbors, and in that case replace it with a white dot.
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.
' This Script will clean up the background of a digitized Writing
VAF.$$PIA=?exeloc\ULangK.png
VAF.$$PIB=?exeloc\ULangK1.png
ANA.Load|0|$$PIA
ANA.Show|0!
'ANA.AnalyzeColor|0|1
$$SRC=&HFFF5FF
$$COL=&HFFFFFF
ANA.ReplaceColorT|0|$$SRC|10|$$COL
$$SRC=&HEADAFE
ANA.ReplaceColorT|0|$$SRC|10|$$COL
$$SRC=&HE4F5FF
ANA.ReplaceColorT|0|$$SRC|10|$$COL
$$SRC=&HC8C0E9
ANA.ReplaceColorT|0|$$SRC|10|$$COL
$$TIM=#dtime#
GSB.Rem_SngPix
CAL.$$TMA=#dsince#|i
DBP.Needed: $$TMA Seconds.
DMP.1
MBX.!
ANA.Show|0!
ANA.Save|0|$$PIB
ENR.
'===========================================================
:Rem_SngPix
ANA.GetRes|0|$$XSZ|$$YSZ
PRT.Size=$$XSZ,$$YSZ
FOR.$$YPO|2|($$YSZ-1)
PRT.$$YPO/$$YSZ
FOR.$$XPO|2|($$XSZ-1)
ANA.getpixelcolor|0|$$XPO|$$YPO|$$PIX
JIV.$$PIX=&HFFFFFF|EndLoop
ANA.gpc4s|0|$$XPO|$$YPO|$$PAA|$$PAB|$$PAC|$$PAD
ANA.gpc4d|0|$$XPO|$$YPO|$$PAE|$$PAF|$$PAG|$$PAH
CAL.$$ERG=($$PAA=&HFFFFFF)+($$PAB=&HFFFFFF)+($$PAC=&HFFFFFF)+($$PAD=&HFFFFFF)+($$PAE=&HFFFFFF)+($$PAF=&HFFFFFF)+($$PAG=&HFFFFFF)+($$PAH=&HFFFFFF)
IVV.$$ERG>5
ANA.Setpixelcolor|0|$$XPO|$$YPO|&HFFFFFF
EIF.
:EndLoop
NEX.
NEX.
RET.
Syntax
ANA.GetPixelColor_4S|P1|P2|P3[|P4][|P5][|P6][|P7]
ANA.GPC4S|P1|P2|P3[|P4][|P5][|P6][|P7]
Parameter Explanation
P1 - Source Image-Register number
P2 - X - Center Pixel Coordinate X-Value
P3 - Y - Center Pixel Coordinate Y-Value
P4 - opt. Variable for returned Color-Value for the Left Pixel.
P5 - opt. Variable for returned Color-Value for the Right Pixel.
P6 - opt. Variable for returned Color-Value for the Upper Pixel.
P7 - opt. Variable for returned Color-Value for the Lower Pixel.
If you omit P4 to P7, TOS is used.
Example
See above.
Remarks
The ANA.GetPixelColor_4S is optimized for Speed. It will use only about 580 Ticks. Therefore the Robot can execute the command typically more then 27500 times per Second.
Limitations:
-
See also: