Class Position


  • public class Position
    extends java.lang.Object
    Holds location, intensity & state information of a pixel in image
    • Constructor Summary

      Constructors 
      Constructor Description
      Position​(int x, int y, int intensityR, int intensityG, int intensityB)
      Holds pixel information i.e.
    • Constructor Detail

      • Position

        public Position​(int x,
                        int y,
                        int intensityR,
                        int intensityG,
                        int intensityB)
        Holds pixel information i.e. its location, intensity & state

        Initially state will be set as inactive ( 0 )

        When Pixel location has been explored, it can be set as active ( 1 )

        And after all neighbours explored for this location, its state to be set as dead ( 2 )

        Parameters:
        x - X-coordinate of Pixel location
        y - Y-coordinate of Pixel location
        intensityR - Red color component intensity at I[y, x]
        intensityG - Green color component intensity at I[y, x]
        intensityB - Blue color component intensity at I[y, x]
    • Method Detail

      • getX

        public int getX()
        Returns:
        X-coordinate of Pixel
      • getY

        public int getY()
        Returns:
        Y-coordinate of Pixel
      • getIntensityR

        public int getIntensityR()
        Returns:
        Red color intensity at this location
      • getIntensityG

        public int getIntensityG()
        Returns:
        Green color intensity at this location
      • getIntensityB

        public int getIntensityB()
        Returns:
        Blue color intensity at this location
      • getState

        public int getState()
        Returns:
        State of pixel ( inactive = 0, active = 1, dead = 2 )
      • setState

        public void setState​(int state)
        Updates state of Pixel
        Parameters:
        state - State of pixel
      • isIntensityRWithInRange

        public boolean isIntensityRWithInRange​(int targetIntensity,
                                               int relaxation)
        Checks whether this pixel's red component intensity satisfies

        targetIntensity - relaxation <= intensity <= targetIntensity + relaxation

        or not

        Parameters:
        targetIntensity - target intensity, with which this pixel's intensity to be compared
        relaxation - targetIntensity - relaxation <= intensity <= targetIntensity + relaxation, needs to be satisfied
        Returns:
        Result of comparison as true / false
      • isIntensityGWithInRange

        public boolean isIntensityGWithInRange​(int targetIntensity,
                                               int relaxation)
        Checks whether this pixel's green component intensity satisfies

        targetIntensity - relaxation <= intensity <= targetIntensity + relaxation

        or not

        Parameters:
        targetIntensity - target intensity, with which this pixel's intensity to be compared
        relaxation - targetIntensity - relaxation <= intensity <= targetIntensity + relaxation, needs to be satisfied
        Returns:
        Result of comparison as true / false
      • isIntensityBWithInRange

        public boolean isIntensityBWithInRange​(int targetIntensity,
                                               int relaxation)
        Checks whether this pixel's blue component intensity satisfies

        targetIntensity - relaxation <= intensity <= targetIntensity + relaxation

        or not

        Parameters:
        targetIntensity - target intensity, with which this pixel's intensity to be compared
        relaxation - targetIntensity - relaxation <= intensity <= targetIntensity + relaxation, needs to be satisfied
        Returns:
        Result of comparison as true / false
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object