/** * Scales down the input by a factor of 2. Every other pixel along both axises is skipped. */ public static void scaleDown2(GrayU8 input , GrayU8 output ) { output.reshape(input.width / 2, input.height / 2); for (int y = 0; y < output.height; y++) { int indexInput = 2*y*input.stride; int indexOutput = y*output.stride; for (int x = 0; x < output.width; x++,indexInput+=2) { output.data[indexOutput++] = input.data[indexInput]; } } }
@Override public void initialize(int imageWidth, int imageHeight, int sensorOrientation) { enhanced.reshape(imageWidth,imageHeight); }
@Override public void initialize(int imageWidth, int imageHeight, int sensorOrientation) { binary.reshape(imageWidth,imageHeight); paint.setStrokeWidth(5.0f*cameraToDisplayDensity); }
@Override public void initialize(int imageWidth, int imageHeight, int sensorOrientation) { paint.setStrokeWidth(4.0f*cameraToDisplayDensity); binary.reshape(imageWidth,imageHeight); }
@Override protected void handleInputChange(int source, InputMethod method, int width, int height) { imageBinary.reshape(width, height); visualizedBinary = ConvertBufferedImage.checkDeclare(width, height, visualizedBinary,BufferedImage.TYPE_INT_BGR); }
@Override public void initialize(int imageWidth, int imageHeight, int sensorOrientation) { gray.reshape(imageWidth,imageHeight); enhanced.reshape(imageWidth,imageHeight); }
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 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(); }
@Override protected void handleInputChange(int source, InputMethod method, final int width, final int height) { super.handleInputChange(source, method, width, height); gray.reshape(width, height); enhancedGray.reshape(width, height); enhancedColor.reshape(width, height); output = ConvertBufferedImage.checkDeclare(width,height,output,output.getType()); BoofSwingUtil.invokeNowOrLater(new Runnable() { @Override public void run() { double zoom = BoofSwingUtil.selectZoomToShowAll(imagePanel,width,height); controls.setZoom(zoom); imagePanel.getVerticalScrollBar().setValue(0); imagePanel.getHorizontalScrollBar().setValue(0); } }); }
/** * <p> * Converts an {@link boofcv.struct.image.GrayS32} 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(GrayS32 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.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; }
/** * <p> * Converts an {@link boofcv.struct.image.GrayU16} 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(GrayU16 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; }
@Override public void initialize(int imageWidth, int imageHeight, int sensorOrientation) { binary.reshape(imageWidth, imageHeight); work.reshape(imageWidth, imageHeight); scaled.reshape(imageWidth/3,imageHeight/3); shrink = new FDistort(); }
@Override public void process(GrayU8 binary) { if(copyForPadding) { work.reshape(binary.width + 2, binary.height + 2); ImageMiscOps.copy(0, 0, 1, 1, binary.width, binary.height, binary, work); alg.process(work,1,1); } else { alg.process(binary,adjustX,adjustY); } // create the contours list contours.reset(); PackedSetsPoint2D_I32 points = alg.getExternalContours(); for( int i = 0; i < points.size(); i++ ) { ContourPacked p = contours.grow(); p.externalIndex = i; p.id = i; } }
@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; } }