@Override public void process(T input, GrayU8 output) { GThresholdImageOps.threshold(input,output,threshold,down); }
@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); }
/** * <p> * Computes the variance based threshold using Otsu's method from an input image. Internally it uses * {@link #computeOtsu(int[], int, int)} and {@link boofcv.alg.misc.GImageStatistics#histogram(ImageGray, double, int[])} * </p> * * @param input Input gray-scale image * @param minValue The minimum value of a pixel in the image. (inclusive) * @param maxValue The maximum value of a pixel in the image. (inclusive) * @return Selected threshold. */ public static double computeOtsu(ImageGray input , double minValue , double maxValue ) { int range = (int)(1+maxValue - minValue); int histogram[] = new int[ range ]; GImageStatistics.histogram(input,minValue,histogram); // Total number of pixels int total = input.width*input.height; return computeOtsu(histogram,range,total)+minValue; }
/** * <p> * Computes the variance based threshold using a modified Otsu method from an input image. Internally it uses * {@link #computeOtsu2(int[], int, int)} and {@link boofcv.alg.misc.GImageStatistics#histogram(ImageGray, double, int[])} * </p> * * @param input Input gray-scale image * @param minValue The minimum value of a pixel in the image. (inclusive) * @param maxValue The maximum value of a pixel in the image. (inclusive) * @return Selected threshold. */ public static int computeOtsu2(ImageGray input , int minValue , int maxValue ) { int range = 1+maxValue - minValue; int histogram[] = new int[ range ]; GImageStatistics.histogram(input,minValue,histogram); // Total number of pixels int total = input.width*input.height; return computeOtsu2(histogram,range,total)+minValue; }
/** * <p> * Computes a threshold which maximizes the entropy between the foreground and background regions. See * {@link #computeEntropy(int[], int, int)} for more details. * </p> * * @see boofcv.alg.misc.GImageStatistics#histogram(ImageGray, double, int[]) * * @param input Input gray-scale image * @param minValue The minimum value of a pixel in the image. (inclusive) * @param maxValue The maximum value of a pixel in the image. (inclusive) * @return Selected threshold. */ public static double computeEntropy(ImageGray input , double minValue , double maxValue ) { int range = (int)(1 + maxValue - minValue); int histogram[] = new int[ range ]; GImageStatistics.histogram(input,minValue,histogram); // Total number of pixels int total = input.width*input.height; return computeEntropy(histogram, range, total)+minValue; }
@Override public void process(T input, GrayU8 output) { work1.reshape(input.width,input.height); work2.reshape(input.width,input.height); GThresholdImageOps.localMean((T)input, output, regionWidth, scale, down, (T)work1, (T)work2); }
@Override public void process(T input, GrayU8 output) { work1.reshape(input.width,input.height); work2.reshape(input.width,input.height); GThresholdImageOps.localGaussian(input, output, regionWidth, scale, down, work1, work2); }
public void process( final BufferedImage image ) { imageInput.reshape(image.getWidth(),image.getHeight()); imageBinary.reshape(image.getWidth(),image.getHeight()); imageOutput.reshape(image.getWidth(),image.getHeight()); ConvertBufferedImage.convertFromSingle(image, imageInput, imageType); final double threshold = GThresholdImageOps.computeOtsu(imageInput,0,255); SwingUtilities.invokeLater(new Runnable() { public void run() { selectThresh.setThreshold((int) threshold); setInputImage(image); selectThresh.getHistogramPanel().update(imageInput); selectThresh.repaint(); }}); doRefreshAll(); }
/** * Add a new pattern to be detected. This function takes in a raw gray scale image and thresholds it. * * @param pattern Gray scale image of the pattern * @param threshold Threshold used to convert it into a binary image * @param lengthSide Length of a side on the square in world units. */ public void addPatternImage(T pattern, double threshold, double lengthSide) { GrayU8 binary = new GrayU8(pattern.width,pattern.height); GThresholdImageOps.threshold(pattern,binary,threshold,false); alg.addPattern(binary, lengthSide); }
public void process( final BufferedImage image ) { imageInput.reshape(image.getWidth(),image.getHeight()); imageBinary.reshape(image.getWidth(),image.getHeight()); imageOutput1.reshape(image.getWidth(),image.getHeight()); imageOutput2.reshape(image.getWidth(),image.getHeight()); imageLabeled.reshape(image.getWidth(),image.getHeight()); ConvertBufferedImage.convertFromSingle(image, imageInput, imageType); final double threshold = GThresholdImageOps.computeOtsu(imageInput,0,255); SwingUtilities.invokeLater(new Runnable() { public void run() { selectThresh.setThreshold((int) threshold); setInputImage(image); selectThresh.getHistogramPanel().update(imageInput); selectThresh.repaint(); }}); doRefreshAll(); }
private synchronized void performWork() { if( filter == null ) return; GThresholdImageOps.threshold(imageInput, imageBinary, selectThresh.getThreshold(), selectThresh.isDown()); filter.process(imageBinary,imageOutput); SwingUtilities.invokeLater(new Runnable() { public void run() { if (work == null || work.getWidth() != imageInput.width || work.getHeight() != imageInput.height) { work = new BufferedImage(imageInput.width, imageInput.height, BufferedImage.TYPE_INT_BGR); } VisualizeBinaryData.renderBinary(selectedVisualize, false, work); gui.setImage(work); gui.setPreferredSize(new Dimension(imageInput.width, imageInput.height)); processedImage = true; gui.repaint(); } }); }
@Override public void process(GrayU8 input) { // Select a reasonable threshold double mean = GThresholdImageOps.computeOtsu(input,0,255); // create a binary image by thresholding ThresholdImageOps.threshold(input, binary, (int)mean, down); // reduce noise with some filtering BinaryImageOps.removePointNoise(binary, filtered1); // draw binary image for output if( showBinary ) { VisualizeImageData.binaryToBitmap(filtered1, false, bitmap, bitmapTmp); } else { ConvertBitmap.boofToBitmap(input,bitmap,bitmapTmp); } // draw the ellipses findContours.process(filtered1,contourOutput); List<Contour> contours = BinaryImageOps.contour(filtered1, ConnectRule.EIGHT,null); resetShapes(); for (Contour contour : contours) { List<Point2D_I32> points = contour.external; if (points.size() < 20) continue; fitShape(points); } finalizeShapes(); visualizationPending = true; } }
GThresholdImageOps.threshold(grayNoBorder,binary,threshold,false);
private synchronized void performWork() { if( filter1 == null || filter2 == null ) return; GThresholdImageOps.threshold(imageInput, imageBinary, selectThresh.getThreshold(), selectThresh.isDown()); filter1.process(imageBinary,imageOutput1); filter2.process(imageOutput1,imageOutput2); List<Contour> found = BinaryImageOps.contour(imageOutput2, connectRule, imageLabeled); if( colors == null || colors.length <= found.size() ) colors = BinaryImageOps.selectRandomColors(found.size(),rand); SwingUtilities.invokeLater(new Runnable() { public void run() { if (work == null || work.getWidth() != imageInput.width || work.getHeight() != imageInput.height) { work = new BufferedImage(imageInput.width, imageInput.height, BufferedImage.TYPE_INT_BGR); } renderVisualizeImage(); gui.setImage(work); gui.setPreferredSize(new Dimension(imageInput.width, imageInput.height)); processedImage = true; gui.repaint(); } }); }
GThresholdImageOps.threshold(edgeIntensity,detected,30,false);
new FDistort(inputGray,scaled).scaleExt().apply(); GThresholdImageOps.threshold(scaled,binary,255/2.0,false); } else { binary.setTo(inputBinary);
private void doProcess() { if( input == null ) return; final BufferedImage temp; if( activeAlg == 0 ) { if( previousBlur != barCanny.getBlurRadius() ) { previousBlur = barCanny.getBlurRadius(); canny = FactoryEdgeDetectors.canny(previousBlur,true, true, imageType, derivType); } double thresh = barCanny.getThreshold()/100.0; canny.process(workImage,(float)thresh*0.1f,(float)thresh,null); List<EdgeContour> contours = canny.getContours(); temp = VisualizeBinaryData.renderContours(contours,null,workImage.width,workImage.height,null); } else { // create a binary image by thresholding GThresholdImageOps.threshold(workImage, binary, barBinary.getThreshold(), barBinary.isDown()); contour.process(binary,labeled); List<Contour> contours = BinaryImageOps.convertContours(contour); temp = VisualizeBinaryData.renderContours(contours,null,0xFF1010, workImage.width,workImage.height,null); } SwingUtilities.invokeLater(new Runnable() { public void run() { panel.setImage(temp); panel.repaint(); }}); }
@Override public List<LineSegment2D_F32> detect(T input) { derivX.reshape(input.width,input.height); derivY.reshape(input.width,input.height); edgeIntensity.reshape(input.width,input.height); detected.reshape(input.width,input.height); gradient.process(input,derivX,derivY); GGradientToEdgeFeatures.intensityAbs(derivX, derivY, edgeIntensity); GThresholdImageOps.threshold(edgeIntensity, detected, edgeThreshold, false); detectorGrid.process(derivX,derivY,detected); MatrixOfList<LineSegment2D_F32> grid = detectorGrid.getFoundLines(); if( connect != null ) { connect.process(grid); } List<LineSegment2D_F32> found = grid.createSingleList(); LineImageOps.mergeSimilar(found, (float) (Math.PI * 0.03), 5f); return found; } }
@Override public void process(GrayU8 input) { GThresholdImageOps.threshold(input,binary,threshold, down);