Tabnine Logo
BinaryImageOps.contour
Code IndexAdd Tabnine to your IDE (free)

How to use
contour
method
in
boofcv.alg.filter.binary.BinaryImageOps

Best Java code snippets using boofcv.alg.filter.binary.BinaryImageOps.contour (Showing top 5 results out of 315)

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

public void process( final GrayU8 input ) {
  // threshold the input image
  inputToBinary.process(input,binary);
  // reduce noise with some filtering
  BinaryImageOps.erode8(binary, 1, filtered);
  BinaryImageOps.dilate8(filtered, 1, binary);
  // Find the contour around the shapes
  contours = BinaryImageOps.contour(binary, ConnectRule.EIGHT,null);
  processImage = true;
  viewUpdated();
}
origin: us.ihmc/DarpaRoboticsChallenge

List<Contour> blobContours = BinaryImageOps.contour(binary, ConnectRule.FOUR, blobs);
origin: us.ihmc/DarpaRoboticsChallenge

public BufferedImage findRoad(BufferedImage src)
{
 // convert into a usable format
 ImageFloat32 input = ConvertBufferedImage.convertFromSingle(src, null, ImageFloat32.class);
 ImageUInt8 binary = new ImageUInt8(input.width, input.height);
 ImageSInt32 blobs = new ImageSInt32(input.width, input.height);
 // the mean pixel value is often a reasonable threshold when creating a binary image
 double mean = ImageStatistics.mean(input);
 // create a binary image
 ThresholdImageOps.threshold(input, binary, (float) mean, true);
 // remove small blobs through erosion and dilation
 // The null in the input indicates that it should internally declare the work image it needs
 // this is less efficient, but easier to code.
 for (int i = 0; i < 1; i++)
 {
   binary = BinaryImageOps.erode8(binary,1, null);
 }
 for (int i = 0; i < 2; i++)
 {
   binary = BinaryImageOps.dilate8(binary,1, null);
 }
 // Detect blobs inside the binary image and assign labels to them
 List<Contour> blobContours = BinaryImageOps.contour(binary, ConnectRule.FOUR, blobs);
 int numBlobs = filterBlobsNotTouchingEdges(blobs, blobContours.size());
 // Render the binary image for output and display it in a window
 BufferedImage dst = VisualizeBinaryData.renderLabeled(blobs, numBlobs, null);
 return dst;
}
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;
  }
}
boofcv.alg.filter.binaryBinaryImageOpscontour

Javadoc

Given a binary image, connect together pixels to form blobs/clusters using the specified connectivity rule. The found blobs will be labeled in an output image and also described as a set of contours. Pixels in the contours are consecutive order in a clockwise or counter-clockwise direction, depending on the implementation. The labeled image will assign background pixels a label of 0 and each blob will be assigned a unique ID starting from 1.

The returned contours are traces of the object. The trace of an object can be found by marking a point with a pen and then marking every point on the contour without removing the pen. It is possible to have the same point multiple times in the contour.

Popular methods of BinaryImageOps

  • erode8
  • dilate8
  • selectRandomColors
    Several blob rending functions take in an array of colors so that the random blobs can be drawn with
  • convertContours
  • relabel
  • dilate4
    Dilates an image according to a 4-neighborhood. If a pixel is connected to any other pixel then its
  • edge4
    Binary operation which is designed to remove all pixels but ones which are on the edge of an object
  • edge8
    Binary operation which is designed to remove all pixels but ones which are on the edge of an object
  • erode4
    Erodes an image according to a 4-neighborhood. Unless a pixel is connected to all its neighbors its
  • invert
    Inverts each pixel from true to false and vis-versa.
  • labelToBinary
    Only converts the specified blobs over into the binary image
  • removePointNoise
    Binary operation which is designed to remove small bits of spurious noise. An 8-neighborhood is used
  • labelToBinary,
  • removePointNoise,
  • thin

Popular in Java

  • Start an intent from android
  • getSupportFragmentManager (FragmentActivity)
  • compareTo (BigDecimal)
  • onRequestPermissionsResult (Fragment)
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • JComboBox (javax.swing)
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Top Sublime Text plugins
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