ANA.GetPixelColor_8

<< Click to Display Table of Contents >>

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

ANA.GetPixelColor_8

ANA.GetPixelColor_8 - Get the Colors of all Neighbour Pixels

Previous Top Next


MiniRobotLanguage (MRL)

 

ANA.GetPixelColor_8

Get the Colors of all 8 Neighbor Pixels of a Single Pixel from an Image-Register (IR)

 

 

Intention

 

This command will read the colors of all 8 Pixels that are  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 8 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.

 

clip0391clip0394

 

The Colors of these Pixels are returned in Variables in P4 to P11.

 

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

 

  You will not see the Robot Painting unless the Show command is been called which leads to an Update in the Show-Window.

 

clip0387

 

 

'

'SPR Script-file: RemoveColors

'Purpose: 

'Author: Theo Gottwald

'Creation date: 12-28-2021 at 20:11:00

'===========================================================

'#EXE:?path\

'#SPI:ForceWrite

 

' This Script will remove a green background

' using special sorting functions.

' The Script is fast and will only take few seconds

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

DMP.1

MBX.Needed: $$TMA Seconds.

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.gpc8|0|$$XPO|$$YPO|$$PAA|$$PAB|$$PAC|$$PAD|$$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.

 

clip0390

 

 

Syntax

 

ANA.GetPixelColor_8|P1|P2|P3[|P4][|P5][|P6][|P7]

ANA.GPC8|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.

P8 - opt. Variable for returned Color-Value for the Upper-Left Pixel.

P9 - opt. Variable for returned Color-Value for the Upper-Right Pixel.

P10 - opt. Variable for returned Color-Value for the Lower-Left Pixel.

P11 - opt. Variable for returned Color-Value for the Lower-RIght Pixel.

If you omit P4 to P7, TOS is used.

 

clip0391clip0394

 

Example

 

See above.

 

 

 

 

Remarks

The ANA.GetPixelColor_8 is optimized for Speed. It will use only about 600 Ticks. Therefore the Robot can execute the command typically more then 27500 times per Second.

 

 

 

Limitations:

 

-

 

 

See also:

 

ANA.GetPixelColor_4D

ANA.GetPixelColor_4D