public ThresholdBlockMean_U8(ConfigLength requestedBlockWidth, double scale , boolean down, boolean thresholdFromLocalBlocks ) { super(requestedBlockWidth,thresholdFromLocalBlocks,GrayU8.class); this.stats = new GrayU8(1,1); this.scale = scale; this.down = down; }
@Override protected GrayU8 createInstance() { return new GrayU8(squareLength,squareLength); } };
@Override public void initialize(int imageWidth, int imageHeight, int sensorOrientation) { blurred = new GrayU8(imageWidth,imageHeight); }
@Override public void initialize(int imageWidth, int imageHeight, int sensorOrientation) { output = new GrayU8(imageWidth,imageHeight); }
@Override public void initialize(int imageWidth, int imageHeight, int sensorOrientation) { binary = new GrayU8(imageWidth,imageHeight); }
@Override public void initialize(int imageWidth, int imageHeight, int sensorOrientation) { binary = new GrayU8(imageWidth,imageHeight); filtered1 = new GrayU8(imageWidth,imageHeight); contourOutput = new GrayS32(imageWidth,imageHeight); paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(3f*cameraToDisplayDensity); paint.setColor(Color.RED); }
public static GrayU8 yuvToGray(ByteBuffer bufferY , int width , int height, int strideRow, GrayU8 output ) { if( output != null ) { output.reshape(width,height); } else { output = new GrayU8(width,height); } int indexDst = 0; for (int y = 0, indexRow=0; y < height; y++,indexRow += strideRow, indexDst += width) { bufferY.position(indexRow); bufferY.get(output.data,indexDst,width); } return output; }
public GrayU8 getGrayU8() { GrayU8 gray = new GrayU8(bufferred.getWidth(),bufferred.getHeight()); ConvertBufferedImage.convertFrom(bufferred,gray); return gray; }
public BinaryContourHelper( BinaryContourInterface alg , boolean copyBinary ) { if( !copyBinary && alg instanceof BinaryContourInterface.Padded ) { padded = (BinaryContourInterface.Padded)alg; subimage = new GrayU8(); padded.setCreatePaddedCopy(false); padded.setCoordinateAdjustment(1,1); } }
/** * 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); }
/** * <p> * Converts an {@link boofcv.struct.image.GrayS8} into a {@link boofcv.struct.image.GrayU8}. * </p> * * @param input Input image which is being converted. Not modified. * @param output (Optional) The output image. If null a new image is created. Modified. * @return Converted image. */ public static GrayU8 convert(GrayS8 input, GrayU8 output) { if (output == null) { output = new GrayU8(input.width, input.height); } else { output.reshape(input.width,input.height); } ImplConvertImage.convert(input, output); return output; }
/** * <p> * Converts an {@link boofcv.struct.image.GrayS16} into a {@link boofcv.struct.image.GrayU8}. * </p> * * @param input Input image which is being converted. Not modified. * @param output (Optional) The output image. If null a new image is created. Modified. * @return Converted image. */ public static GrayU8 convert(GrayS16 input, GrayU8 output) { if (output == null) { output = new GrayU8(input.width, input.height); } else { output.reshape(input.width,input.height); } ImplConvertImage.convert(input, output); return output; }
/** * Converts a {@link Planar} into a {@link ImageGray} by computing the average value of each pixel * across all the bands. * * @param input Input Planar image that is being converted. Not modified. * @param output (Optional) The single band output image. If null a new image is created. Modified. * @return Converted image. */ public static GrayU8 average( Planar<GrayU8> input , GrayU8 output ) { if (output == null) { output = new GrayU8(input.width, input.height); } else { output.reshape(input.width,input.height); } ImplConvertPlanarToGray.average(input, output); return output; }
/** * Converts a {@link InterleavedU8} into a {@link GrayU8} by computing the average value of each pixel * across all the bands. * * @param input (Input) The ImageInterleaved that is being converted. Not modified. * @param output (Optional) The single band output image. If null a new image is created. Modified. * @return Converted image. */ public static GrayU8 average( InterleavedU8 input , GrayU8 output ) { if (output == null) { output = new GrayU8(input.width, input.height); } else { output.reshape(input.width,input.height); } ConvertInterleavedToSingle.average(input, output); return output; }
public FiducialProcessor() { super(ImageType.single(GrayU8.class)); detected = new FiducialDetector.Detected[3]; for (int i = 0; i < detected.length; i++) { detected[i] = new FiducialDetector.Detected(); detected[i].binary = new GrayU8(1,1); detected[i].location = new Quadrilateral_F64(); } }
public DetectLineSegmentsGridRansac(GridRansacLineDetector<D> detectorGrid, ConnectLinesGrid connect, ImageGradient<T,D> gradient, double edgeThreshold , Class<T> imageType , Class<D> derivType ) { this.detectorGrid = detectorGrid; this.connect = connect; this.gradient = gradient; this.edgeThreshold = edgeThreshold; derivX = GeneralizedImageOps.createSingleBand(derivType, 1, 1); derivY = GeneralizedImageOps.createSingleBand(derivType, 1, 1); edgeIntensity = new GrayF32(1,1); detected = new GrayU8(1,1); }
/** * * @see FactoryThresholdBinary#localOtsu(boolean, ConfigLength, double, double, boolean, Class) */ public static <T extends ImageGray<T>> GrayU8 localOtsu(T input, GrayU8 output, boolean otsu2, ConfigLength width, double tuning , double scale, boolean down) { InputToBinary<T> alg = FactoryThresholdBinary.localOtsu(otsu2,width,tuning,scale,down,input.getImageType().getImageClass()); if( output == null ) output = new GrayU8(input.width,input.height); alg.process(input,output); return output; }
public static void main(String[] args) { BufferedImage image = UtilImageIO.loadImage(UtilIO.pathExample("segment/berkeley_horses.jpg")); GrayU8 gray = new GrayU8(image.getWidth(),image.getHeight()); ConvertBufferedImage.convertFrom(image, gray); WatershedVincentSoille1991 alg = FactorySegmentationAlg.watershed(ConnectRule.FOUR); alg.process(gray); GrayS32 pixelToRegion = alg.getOutput(); VisualizeRegions.watersheds(pixelToRegion,image,0); alg.removeWatersheds(); int numRegions = alg.getTotalRegions(); BufferedImage outRegions = VisualizeRegions.regions(pixelToRegion,numRegions,null); ShowImages.showWindow(image, "Watershed"); ShowImages.showWindow(outRegions, "Regions"); } }