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

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

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

origin: lessthanoptimal/BoofAndroidDemo

BinaryImageOps.dilate4(binary,1,afterOps);
break;
BinaryImageOps.dilate8(binary, 1, afterOps);
break;
BinaryImageOps.erode4(binary, 1, afterOps);
break;
BinaryImageOps.erode8(binary, 1, afterOps);
break;
BinaryImageOps.edge4(binary, afterOps);
break;
BinaryImageOps.edge8(binary, afterOps);
break;
BinaryImageOps.removePointNoise(binary, afterOps);
break;
BinaryImageOps.thin(binary,50,afterOps);
break;
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: 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

  @Override
  protected void detectorProcess(ImageGray input, GrayU8 binary) {
//        System.out.println("processing image "+count++);
    binaryToContour.process(binary,labeled);

    contours = BinaryImageOps.convertContours(binaryToContour);

    int minContourPixels = minimumContourSize.computeI(Math.min(input.width,input.height));

    polylines.clear();
    GrowQueue_I32 indices = new GrowQueue_I32();
    for (int i = 0; i < contours.size(); i++) {
      List<Point2D_I32> contour = contours.get(i).external;
      if( contour.size() < minContourPixels )
        continue;
      if( contourToPolyline.process(contour,indices) ) {
        List<Point2D_I32> l = new ArrayList<>();
        for (int j = 0; j < indices.size; j++) {
          l.add( contour.get( indices.get(j)));
        }
        polylines.add(l);
      }
    }
  }

origin: org.boofcv/recognition

public boolean process(T gray) {
  binary.reshape(gray.width, gray.height);
  eroded.reshape(gray.width, gray.height);
  inputToBinary.process(gray,binary);
  // erode to make the squares separated
  BinaryImageOps.erode8(binary, 1, eroded);
  return findSeeds.process(gray, eroded);
}
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/visualize

public ImageBinaryLabeledPanel(GrayS32 labelImage, int maxValues , long randSeed ) {
  this();
  this.labelImage = labelImage;
  img = new BufferedImage(labelImage.getWidth(), labelImage.getHeight(),BufferedImage.TYPE_INT_RGB);
  setPreferredSize(new Dimension(labelImage.getWidth(), labelImage.getHeight()));
  setMinimumSize(getPreferredSize());
  setMaximumSize(getPreferredSize());
  Random rand = new Random(randSeed);
  colors = BinaryImageOps.selectRandomColors(maxValues,rand);
  VisualizeBinaryData.renderLabeled(labelImage, colors, img);
}
origin: us.ihmc/DarpaRoboticsChallenge

/**
* Set the value of any blob which does not touches the top or bottom image border to zero.  Then
* relabel the binary image.
*/
private int filterBlobsNotTouchingEdges(ImageSInt32 labeled, int numLabels)
{
 int value[] = new int[numLabels + 1];
 for (int i = 0; i < value.length; i++)
 {
   value[i] = 0;
 }
 for (int x = 0; x < labeled.width; x++)
 {
   int top = labeled.startIndex + x;
   int bottom = labeled.startIndex + labeled.stride * (labeled.height - 1) + x;
   value[labeled.data[top]] = labeled.data[top];
   value[labeled.data[bottom]] = labeled.data[bottom];
 }
 int count = 1;
 for (int i = 0; i < value.length; i++)
 {
   if (value[i] != 0)
   {
    value[i] = count++;
   }
 }
 // relabel the image to remove blobs with holes inside
 BinaryImageOps.relabel(labeled, value);
 return count - 1;
}
origin: org.boofcv/demonstrations

@Override
protected List<Contour> getContours() {
  BinaryContourFinder contour = alg.getDetectorSquare().getDetector().getContourFinder();
  List<Contour> contours = BinaryImageOps.convertContours(contour);
  return contours;
}
origin: org.boofcv/boofcv-swing

public ImageBinaryLabeledPanel(GrayS32 labelImage, int maxValues , long randSeed ) {
  this();
  this.labelImage = labelImage;
  img = new BufferedImage(labelImage.getWidth(), labelImage.getHeight(),BufferedImage.TYPE_INT_RGB);
  setPreferredSize(new Dimension(labelImage.getWidth(), labelImage.getHeight()));
  setMinimumSize(getPreferredSize());
  setMaximumSize(getPreferredSize());
  Random rand = new Random(randSeed);
  colors = BinaryImageOps.selectRandomColors(maxValues,rand);
  VisualizeBinaryData.renderLabeled(labelImage, colors, img);
}
origin: org.boofcv/feature

/**
 * Merges regions together and updates the provided data structures for said changes.
 *
 * @param pixelToRegion (Input/Output) Image used to convert pixel location in region ID.  Modified.
 * @param regionMemberCount (Input/Output) List containing how many pixels belong to each region.  Modified.
 */
public void performMerge( GrayS32 pixelToRegion ,
             GrowQueue_I32 regionMemberCount ) {
  // update member counts
  flowIntoRootNode(regionMemberCount);
  // re-assign the number of the root node and trim excessive nodes from the lists
  setToRootNodeNewID(regionMemberCount);
  // change the labels in the pixelToRegion image
  BinaryImageOps.relabel(pixelToRegion, mergeList.data);
}
origin: us.ihmc/DarpaRoboticsChallenge

  binary = BinaryImageOps.erode8(binary, 1,null);
  binary = BinaryImageOps.dilate8(binary,1, null);
List<Contour> blobContours = BinaryImageOps.contour(binary, ConnectRule.FOUR, blobs);
origin: org.boofcv/boofcv-ip

/**
 * Finds the external contours only in the image
 * @param input Input binary image.  Not modified.
 * @param rule Connectivity rule.  Can be 4 or 8.  8 is more commonly used.
 * @return List of found contours for each blob.
 */
public static List<Contour> contourExternal(GrayU8 input, ConnectRule rule ) {
  BinaryContourFinder alg = FactoryBinaryContourFinder.linearExternal();
  alg.setConnectRule(rule);
  alg.process(input);
  return convertContours(alg);
}
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: org.boofcv/demonstrations

@Override
protected List<Contour> getContours() {
  BinaryLabelContourFinder contour = detector.getDetector().getEllipseDetector().getEllipseDetector().getContourFinder();
  return BinaryImageOps.convertContours(contour);
}
origin: org.boofcv/demonstrations

@Override
protected List<Contour> getContours() {
  BinaryLabelContourFinder contour = detector.getDetector().getEllipseDetector().getEllipseDetector().getContourFinder();
  return BinaryImageOps.convertContours(contour);
}
origin: org.boofcv/demonstrations

@Override
protected List<Contour> getContours() {
  BinaryContourFinder contour = alg.getFindSeeds().getDetectorSquare().getDetector().getContourFinder();
  return BinaryImageOps.convertContours(contour);
}
origin: org.boofcv/demonstrations

List<Contour> contours = BinaryImageOps.convertContours(contour);
g2.setStroke(new BasicStroke(1));
VisualizeBinaryData.render(contours, null,Color.CYAN, scale, g2);
origin: org.boofcv/boofcv-ip

alg.process(input,output);
return convertContours(alg);
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();
    }});
}
boofcv.alg.filter.binaryBinaryImageOps

Javadoc

Contains a standard set of operations performed on binary images. A pixel has a value of false if it is equal to zero or true equal to one.

NOTE: If an element's value is not zero or one then each function's behavior is undefined.

Most used methods

  • erode8
  • contour
  • 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
  • invert,
  • labelToBinary,
  • removePointNoise,
  • thin

Popular in Java

  • Making http requests using okhttp
  • scheduleAtFixedRate (Timer)
  • setContentView (Activity)
  • runOnUiThread (Activity)
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Top PhpStorm 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