Package tritechgemini.detect
Class BackgroundSub
java.lang.Object
tritechgemini.detect.BackgroundSub
Really simple background subtraction class
- Author:
- Doug Gillespie
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint[]calcBackground(byte[] data, int nBearing, int nRange) byte[]Get the current background.Get the last record used for a background subtraction.doubleGet the scaling factor for background removal.byte[]getSTD()Get the standard deviation of the data.short[]getSTDI()Get the standard deviation of the data in short integers.intBackground scale is 1/the update fraction, i.e.intCount of background updates.int[]Get the variance of the data.booleanCheck whether or not calculating the variance (and STD) in the levels as the means.byte[]removeBackground(byte[] data, int nBearing, int nRange, boolean updateFirst) Remove background from raw image dataremoveBackground(SonarImageRecordI geminiRecord, boolean updateFirst) Remove background from an image record.voidRest the updatecount to zero.voidsetCalculateVariance(boolean calculateVariance) Say whether or not to calculate the variance (and STD) in the levels as the means.voidsetRemovalScale(double removalScale) Set a scaling factor for background removal.voidsetRemovalScale(double backgroundScale, double backgroundSTDs) voidsetTimeConstant(int timeConstant) Background scale is 1/the update fraction, i.e.
-
Constructor Details
-
BackgroundSub
public BackgroundSub()
-
-
Method Details
-
removeBackground
Remove background from an image record.- Parameters:
geminiRecord- Image recordupdateFirst- update the background measurement before subtraction- Returns:
- clone of the input record with updated background.
-
removeBackground
public byte[] removeBackground(byte[] data, int nBearing, int nRange, boolean updateFirst) Remove background from raw image data- Parameters:
data- raw image dataupdateFirst- update the background measurement before subtraction- Returns:
- new array of data with background subtracted.
-
calcBackground
public int[] calcBackground(byte[] data, int nBearing, int nRange) -
getBackground
public byte[] getBackground()Get the current background.
Note that this may be greater in dimension than the current image size, but should never be smaller- Returns:
- background converted to byte.
-
getVariance
public int[] getVariance()Get the variance of the data.
Note that this may be greater in dimension than the current image size, but should never be smaller- Returns:
- variance
-
getSTDI
public short[] getSTDI()Get the standard deviation of the data in short integers.
Note that this may be greater in dimension than the current image size, but should never be smaller- Returns:
- the standard deviation of the data.
-
getSTD
public byte[] getSTD()Get the standard deviation of the data.
Note that this may be greater in dimension than the current image size, but should never be smaller- Returns:
- the standard deviation of the data.
-
getTimeConstant
public int getTimeConstant()Background scale is 1/the update fraction, i.e. a big number updates slowly.- Returns:
- the backgroundScale
-
setTimeConstant
public void setTimeConstant(int timeConstant) Background scale is 1/the update fraction, i.e. a big number updates slowly.- Parameters:
backgroundScale- the backgroundScale to set
-
setRemovalScale
public void setRemovalScale(double removalScale) Set a scaling factor for background removal. 1. is remove the background as is, 1.1 would remove a bit more than the background, etc.- Parameters:
removalScale-
-
setRemovalScale
public void setRemovalScale(double backgroundScale, double backgroundSTDs) -
getRemovalScale
public double getRemovalScale()Get the scaling factor for background removal. 1. is remove the background as is, 1.1 would remove a bit more than the background, etc.- Returns:
- removal scale
-
isCalculateVariance
public boolean isCalculateVariance()Check whether or not calculating the variance (and STD) in the levels as the means. Only worth doing this if you want these stats for your detector- Returns:
- the calculateVariance
-
setCalculateVariance
public void setCalculateVariance(boolean calculateVariance) Say whether or not to calculate the variance (and STD) in the levels as the means. Only worth doing this if you want these stats for your detector- Parameters:
calculateVariance- the calculateVariance to set
-
getUpdateCount
public int getUpdateCount()Count of background updates. Can be used to prevent detection for a while as the background settles.- Returns:
- the updateCount
-
resetUpdateCount
public void resetUpdateCount()Rest the updatecount to zero. this gets called after an OOW has finished, which can cause a lot of false dets when it goes back in the water. This will cause anything using the data to know the background isn't stable and to wait a bit before trying to detect. -
getLastBackgroundRecord
Get the last record used for a background subtraction.- Returns:
- last record used in background subtraction.
-