Class Image
- java.lang.Object
-
- in.itzmeanjan.filterit.segmentation.Image
-
public class Image extends java.lang.Object
Image abstraction class used for performing neighbourhood ( N8 ) ops with ease, works only on grayscale imageAny pixel ( instance of Position class ) can stay in one of possible three states
0 - Pixel is in inactive state
1 - Pixel is in active state
2 - Pixel is in dead state
-
-
Constructor Summary
Constructors Constructor Description Image(int width, int height)
Constructor to be used if you don't have all pixel intensities available right away, those can be updated laterImage(int width, int height, Position[][] positions)
Constructor to be used if you've all pixel intensities available right away in form of matrix
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Image
fromBufferedImage(java.awt.image.BufferedImage img)
Given a buffered image, it'll compute instance of Image class holding same information, but this class has utility methods which can help us in doing neighbourhood ops in a better fashionjava.util.ArrayList<Position>
getNeighbourhoodOfOrderX(Position position, int order)
Can obtain all valid pixel locations around specified pixel P, for specific order of neighbourhoodjava.util.ArrayList<Position>
getNeighbourhoodOfOrderXInclusive(Position position, int order)
Can obtain all valid pixel locations around specified pixel P, for specific order of neighbourhoodPosition
getPosition(int x, int y)
Returns pixel information at I[y][x]Position[][]
getPositions()
Returns a matrix of all pixels present in image, in ordered fashionjava.util.ArrayList<Position>
getUnexploredN8(Position position)
Obtains only those pixel locations ( in order 1 neighbourhood - N8 ) which are in inactive state ( state 0 )void
setActive(int x, int y)
Set pixel state at I[y][x] to active ( 1 )void
setPosition(int x, int y, Position position)
Sets pixel information at I[y][x]
-
-
-
Constructor Detail
-
Image
public Image(int width, int height, Position[][] positions)
Constructor to be used if you've all pixel intensities available right away in form of matrix- Parameters:
width
- Width of imageheight
- Height of imagepositions
- Pixel locations of image ( in form of matrix ), in number width * height
-
Image
public Image(int width, int height)
Constructor to be used if you don't have all pixel intensities available right away, those can be updated later- Parameters:
width
- Width of imageheight
- Height of image
-
-
Method Detail
-
fromBufferedImage
public static Image fromBufferedImage(java.awt.image.BufferedImage img)
Given a buffered image, it'll compute instance of Image class holding same information, but this class has utility methods which can help us in doing neighbourhood ops in a better fashion- Parameters:
img
- Buffered image from which Image instance to be created- Returns:
- Instance of Image class, holding information grabbed from `img`
-
getPosition
public Position getPosition(int x, int y)
Returns pixel information at I[y][x]- Parameters:
x
- X-coordinate of Pixel positiony
- Y-coordinate of Pixel position- Returns:
- Returns pixel at I[y][x]
-
setPosition
public void setPosition(int x, int y, Position position)
Sets pixel information at I[y][x]- Parameters:
x
- X-coordinate of Pixel positiony
- Y-coordinate of Pixel positionposition
- Pixel information we want to set at I[y][x]
-
getNeighbourhoodOfOrderX
public java.util.ArrayList<Position> getNeighbourhoodOfOrderX(Position position, int order)
Can obtain all valid pixel locations around specified pixel P, for specific order of neighbourhoodDoesn't include itself in neighbourhood, for inclusive version, check below implementation
- Parameters:
position
- Location of pixel around which neighbouring pixels to be extractedorder
- Order of neighbourhood to be considered- Returns:
- List of all pixel locations around it, present in order-X neighbourhood ( except itself )
-
getNeighbourhoodOfOrderXInclusive
public java.util.ArrayList<Position> getNeighbourhoodOfOrderXInclusive(Position position, int order)
Can obtain all valid pixel locations around specified pixel P, for specific order of neighbourhoodIncludes itself in neighbourhood, for exclusive version, check above implementation
- Parameters:
position
- Location of pixel around which neighbouring pixels to be extractedorder
- Order of neighbourhood to be considered- Returns:
- List of all pixel locations around it, present in order-X neighbourhood ( including itself )
-
getUnexploredN8
public java.util.ArrayList<Position> getUnexploredN8(Position position)
Obtains only those pixel locations ( in order 1 neighbourhood - N8 ) which are in inactive state ( state 0 )- Parameters:
position
- Pixel location- Returns:
- Set of pixels in order 1 neighbourhood of `position`, which are in *inactive* state
-
setActive
public void setActive(int x, int y)
Set pixel state at I[y][x] to active ( 1 )- Parameters:
x
- X-coordinate of Pixely
- Y-coordinate of Pixel
-
getPositions
public Position[][] getPositions()
Returns a matrix of all pixels present in image, in ordered fashion- Returns:
- All pixels present in image
-
-