Tabnine Logo
GThresholdImageOps
Code IndexAdd Tabnine to your IDE (free)

How to use
GThresholdImageOps
in
boofcv.alg.filter.binary

Best Java code snippets using boofcv.alg.filter.binary.GThresholdImageOps (Showing top 20 results out of 315)

origin: org.boofcv/boofcv-ip

@Override
public void process(T input, GrayU8 output) {
  GThresholdImageOps.threshold(input,output,threshold,down);
}
origin: org.boofcv/boofcv-ip

@Override
public void process(T input, GrayU8 output) {
  double threshold = GThresholdImageOps.computeOtsu(input,minValue,maxValue);
  GThresholdImageOps.threshold(input,output,threshold,down);
}
origin: org.boofcv/boofcv-ip

@Override
public void process(T input, GrayU8 output) {
  double threshold = GThresholdImageOps.computeEntropy(input, minValue, maxValue);
  GThresholdImageOps.threshold(input,output,threshold,down);
}
origin: org.boofcv/boofcv-ip

/**
 * <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;
}
origin: org.boofcv/boofcv-ip

/**
 * <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;
}
origin: org.boofcv/boofcv-ip

/**
 * <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;
}
origin: org.boofcv/boofcv-ip

@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);
}
origin: org.boofcv/boofcv-ip

@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);
}
origin: org.boofcv/demonstrations

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();
}
origin: org.boofcv/recognition

/**
 * 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);
}
origin: org.boofcv/demonstrations

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();
}
origin: org.boofcv/demonstrations

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();
    }
  });
}
origin: lessthanoptimal/BoofAndroidDemo

  @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;
  }
}
origin: org.boofcv/recognition

GThresholdImageOps.threshold(grayNoBorder,binary,threshold,false);
origin: org.boofcv/demonstrations

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();
    }
  });
}
origin: org.boofcv/demonstrations

GThresholdImageOps.threshold(edgeIntensity,detected,30,false);
origin: org.boofcv/recognition

    new FDistort(inputGray,scaled).scaleExt().apply();
  GThresholdImageOps.threshold(scaled,binary,255/2.0,false);
} else {
  binary.setTo(inputBinary);
origin: org.boofcv/demonstrations

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();
    }});
}
origin: org.boofcv/feature

  @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;
  }
}
origin: lessthanoptimal/BoofAndroidDemo

@Override
public void process(GrayU8 input) {
  GThresholdImageOps.threshold(input,binary,threshold, down);
boofcv.alg.filter.binaryGThresholdImageOps

Javadoc

Weakly typed version of ThresholdImageOps.

Most used methods

  • threshold
    Applies a global threshold across the whole image. If 'down' is true, then pixels with values ≤ to '
  • computeOtsu
    Computes the variance based Otsu threshold from a histogram directly. The threshold is selected by m
  • computeEntropy
    Computes a threshold which maximizes the entropy between the foreground and background regions. See
  • computeOtsu2
    Computes a modified modified Otsu threshold which maximizes the distance from the distributions mean
  • localGaussian
    Thresholds the image using a locally adaptive threshold that is computed using a local square regio
  • localMean
    Thresholds the image using a locally adaptive threshold that is computed using a local square regio

Popular in Java

  • Finding current android device location
  • putExtra (Intent)
  • addToBackStack (FragmentTransaction)
  • getApplicationContext (Context)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now