/** * * @param binary Binary image with a border of zeros added to the outside. */ public void setInputs(GrayU8 binary ) { this.binary = binary; if( rule == ConnectRule.EIGHT ) { setOffsets8(offsetsBinary,binary.stride); } else { setOffsets4(offsetsBinary,binary.stride); } }
@Override public ConnectRule getConnectRule() { return finder.getConnectRule(); } }
@Override public void setMinContour(int length) { finder.setMinContourSize(length); }
@Override public void process(T input, GrayU8 output) { double threshold = GThresholdImageOps.computeOtsu(input,minValue,maxValue); GThresholdImageOps.threshold(input,output,threshold,down); }
@Override public void process(T input, GrayU8 output) { double threshold = GThresholdImageOps.computeEntropy(input, minValue, maxValue); GThresholdImageOps.threshold(input,output,threshold,down); }
@Override public void process(T input, GrayU8 output) { GThresholdImageOps.threshold(input,output,threshold,down); }
/** * Searches in a circle around the current point in a clock-wise direction for the first black pixel. */ private boolean searchNotZero() { // Unrolling here results in about a 10% speed up if( ruleN == 4 ) return searchNotOne4(); else return searchNotOne8(); }
protected void updateHistogramX(int x0, int y0, GrayU8 input) { int indexInput = input.startIndex + y0*input.stride + x0-1; for (int y = 0; y < regionWidth; y++) { histogram[input.data[indexInput] & 0xFF]--; histogram[input.data[indexInput+regionWidth] & 0xFF]++; indexInput += input.stride; } otsu.compute(histogram,histogram.length,numPixels); } protected void updateHistogramY(int x0, int y0, GrayU8 input) {
@Override public void setSaveInnerContour(boolean enabled) { finder.setSaveInternalContours(enabled); }
@Override public void setConnectRule(ConnectRule rule) { finder.setConnectRule(rule); }
@Override public int getMinContour() { return alg.getMinContourLength(); }
/** * Applies the dynamically computed threshold to each pixel in the image, one block at a time */ private void applyThreshold( T input, GrayU8 output ) { for (int blockY = 0; blockY < stats.height; blockY++) { for (int blockX = 0; blockX < stats.width; blockX++) { thresholdBlock(blockX,blockY,input,output); } } }
public LinearExternalContours( ConnectRule rule ) { tracer = new Tracer(rule); }
/** * Configures the detector * * @param regionWidthLength How wide the local square region is. * @param tuning Tuning parameter. 0 = standard Otsu. Greater than 0 will penalize zero texture. */ public ThresholdLocalOtsu(boolean otsu2, ConfigLength regionWidthLength, double tuning, double scale, boolean down ) { this.regionWidthLength = regionWidthLength; this.otsu = new ComputeOtsu(otsu2,tuning,down,scale); }
@Override public int getMinContour() { return finder.getMinContourSize(); }
@Override public int getMaxContour() { return finder.getMaxContourSize(); }
@Override public void setMaxContour(int length) { alg.setMaxContourLength(length); }
@Override public int getMaxContour() { return alg.getMaxContourLength(); }
/** * Configures the algorithm. * * @param rule Connectivity rule. 4 or 8 */ public LinearContourLabelChang2004( ConnectRule rule ) { tracer = new ContourTracer(rule); }
protected void updateHistogramY(int x0, int y0, GrayU8 input) { int offset = regionWidth*input.stride; for (int x = 0; x < regionWidth; x++) { int indexInput = input.startIndex + (y0-1)*input.stride + x0+x; histogram[input.data[indexInput] & 0xFF]--; histogram[input.data[indexInput+offset] & 0xFF]++; } otsu.compute(histogram,histogram.length,numPixels); }