Package grp25.captcha
Class ImgWithTag
- java.lang.Object
-
- grp25.captcha.ImgWithTag
-
class ImgWithTag extends java.lang.ObjectA wrapper class for a image and its patches with tags.
-
-
Constructor Summary
Constructors Constructor Description ImgWithTag(java.io.File img, int rows, int cols, boolean hab)A wrapper class for a image and its patches with tags.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.FilegetImg()Get the source image file.(package private) java.awt.image.BufferedImagegetPatch(int row, int col)Get the BufferedImage of patch of the given coordinate.(package private) TaggetTag(int row, int col)Get the tag of patch given its row and column index.(package private) java.lang.StringgetType()Get the file extension of source image filevoidsetAll(boolean hab)Set all patches to given tag.(package private) voidsetTag(int row, int col, Tag t)Set the tag of the given patch to given value.
-
-
-
Constructor Detail
-
ImgWithTag
ImgWithTag(java.io.File img, int rows, int cols, boolean hab) throws java.io.IOExceptionA wrapper class for a image and its patches with tags.- Parameters:
img- The source Imagerows- The number of rows that the image will be sliced intocols- The number of cols that the image will be sliced intohab- The default value of whether each patches are habitable or not. This argument should be generalize to generalTagvalue.- Throws:
java.io.IOException- The exception be raised when reading images from the file system
-
-
Method Detail
-
getPatch
java.awt.image.BufferedImage getPatch(int row, int col)Get the BufferedImage of patch of the given coordinate.- Parameters:
row- The row coordinate (y).col- The col coordinate (x).- Returns:
- The BufferedImage of patch of the given coordinate.
-
getTag
Tag getTag(int row, int col)
Get the tag of patch given its row and column index.- Parameters:
row- The row index of patch.col- The column index of patch.- Returns:
- The tag of given row and column.
-
setTag
void setTag(int row, int col, Tag t)Set the tag of the given patch to given value.- Parameters:
row- The row index of patch to set.col- The column index of patch to sett- The tag that the patch to set to.
-
getType
java.lang.String getType() throws java.io.IOExceptionGet the file extension of source image file- Returns:
- The file extension of source image file.
- Throws:
java.io.IOException- IO excption generated from operations about file.
-
getImg
public java.io.File getImg()
Get the source image file.- Returns:
- The source image file.
-
setAll
public void setAll(boolean hab)
Set all patches to given tag. This function should be generalize so that it can work with anyTag.- Parameters:
hab- Whether all patches are inhabitable.
-
-