Image/Pixel-Color Operations

<< Click to Display Table of Contents >>

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

Image/Pixel-Color Operations

ANA.GetPixelColor - Get the Color of a Single Pixel of an IR

Previous Top Next


MiniRobotLanguage (MRL)

 

ANA.GetPixelColor

Get the Color of a Single Pixel from an Image-Register (IR)

 

 

Intention

 

This command will read the color of a Single Pixel in an IR. While that does not Sound much, it enables you to do unlimited complex Image processing. Use it together with other Commands like ANA.SetPixelColor.

 

With this command, the returned value is the 24-bit color of the Pixel.

 

1. Remove Green Background on a picture using an SPR-Script

In this Sample we will remove the Background on a picture using the SPR.

For this we will read the Pixel, check if its mostly Green, and in that case replace

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". Freerun

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.

 

Editordbw

 

  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\Sarah_640.jpg

VAF.$$PIB=?pattern\Mahakala2.png

ANA.Load|0|$$PIA

ANA.Load|1|$$PIB

ANA.Show|0!

ANA.Show|1!

ANA.GetRes|0|$$XSZ|$$YSZ

FOR.$$YPO|1|$$YSZ

  DBP.$$YPO/$$YSZ

  FOR.$$XPO|1|$$XSZ/2

    ANA.GetPixelRGB|0|$$XPO|$$YPO|$$RED|$$GRN|$$BLU    

    CAL.$$ERG=($$GRN>&H80)+($$GRN>$$BLU)+($$GRN>$$RED))

    IVV.$$ERG>2

      ANA.getpixelcolor|1|$$XPO|$$YPO|$$PIX

      ANA.Setpixelcolor|0|$$XPO|$$YPO|$$PIX

    EIF.    

  NEX.

NEX.

CAL.$$TIM=#time#-$$TIM

DBP.Used Time in Seconds: $$TIM

ANA.Show|0!

ENR.

 

 

 

Sara_Green     Maha_01RemoveBG_03

This box is filled and it is drawn with inverted background color.                                                 The second Part of the Script will draw 2500 random Lines.

 

Speeddump gpc

The Speed-dump shows that the Robot can read about 40.000 Pixels per second.

 

 

2. Color-Processing

 

In this Sample we will additionally change the Colors.For this we use the two Commands:

      ANA.getpixelcolor|1|$$XPO|$$YPO|$$PIX

' This is just for example normally you would use ANA.GetPixelColor_RGB which combines these commands.

      ANA.Split_Color_RGB|$$PIX|$$COR|$$COG|$$COB

' We Combine the Colors in away that Blue and Green is exchanged.

      ANA.Combine_Color_RGB|$$COG|$$COR|$$COB|$$PIX  

' And Set the Pixel

      ANA.Setpixelcolor|0|$$XPO|$$YPO|$$PIX

 

And then Paint the Picture.

In the SPR you can use virtually unlimited Graphics Sources to be combined.

 

.

' Here is the Code.

' On my Computer it uses 5 MinutesProcessing time for a Picture of Medium size in the Editor in "Free-Run Mode".

VAN.$$TIM=#time#

VAF.$$PIA=?pattern\Sarah_640.jpg

VAF.$$PIB=?pattern\Mahakala2.png

ANA.Load|0|$$PIA

ANA.Load|1|$$PIB

ANA.GetRes|0|$$XSZ|$$YSZ

FOR.$$YPO|1|$$YSZ

  DBP.$$YPO/$$YSZ

  FOR.$$XPO|1|$$XSZ/2

    ANA.GetPixelRGB|0|$$XPO|$$YPO|$$RED|$$GRN|$$BLU    

    CAL.$$ERG=($$GRN>&H80)+($$GRN>$$BLU)+($$GRN>$$RED))

    IVV.$$ERG>2

      ANA.getpixelcolor|1|$$XPO|$$YPO|$$PIX

      ANA.Split_Color_RGB|$$PIX|$$COR|$$COG|$$COB

      ANA.Combine_Color_RGB|$$COG|$$COR|$$COB|$$PIX  

      ANA.Setpixelcolor|0|$$XPO|$$YPO|$$PIX

    EIF.    

  NEX.

NEX.

CAL.$$TIM=#time#-$$TIM

DBP.Used Time in Seconds: $$TIM

DMP.1

ANA.Show|0!

ENR.

 

Sara_Green     Maha_01Sarah_3

The Script used 306 Seconds to complete process the picture.

 

 

Here is the Speed-Dump:

SPD1

 

 

 

 

Syntax

 

ANA.GetPixelColor[|P1][|P2][|P3]

 

Parameter Explanation

 

P1 - Source Image-Register number

P2 - X1 - Upper Left Coordinat X-Value

P3 - Y1 - Upper Left Coordinat Y-Value

P4 - opt. Variable for returned Color-Value. If omitted TOS is used.

 

 

 

Example

 

See above.

 

 

 

 

Remarks

The ANA.GetPixelColor is optimized for Speed. It will use only about 365 Ticks. Therefore the Robot could read more then 43000 Pixels per Second.

 

 

 

Limitations:

 

-

 

 

See also: