public ThresholdBlockMean_F32(ConfigLength requestedBlockWidth, double scale , boolean down, boolean thresholdFromLocalBlocks ) { super(requestedBlockWidth,thresholdFromLocalBlocks,GrayF32.class); this.stats = new GrayF32(1,1); this.scale = (float)scale; this.down = down; }
public static void trace(GrayF32 featureIntensity , GrayS16 hessianXX, GrayS16 hessianYY ) { final int width = hessianXX.width; final int height = hessianXX.height; if( featureIntensity == null ) { featureIntensity = new GrayF32(width,height); } for( int y = 0; y < height; y++ ) { int indexXX = hessianXX.startIndex + y*hessianXX.stride; int indexYY = hessianYY.startIndex + y*hessianYY.stride; int indexInten = featureIntensity.startIndex + y*featureIntensity.stride; for( int x = 0; x < width; x++ ) { int dxx = hessianXX.data[indexXX++]; int dyy = hessianYY.data[indexYY++]; featureIntensity.data[indexInten++] = dxx + dyy; } } }
public static void trace(GrayF32 featureIntensity , GrayF32 hessianXX, GrayF32 hessianYY ) { final int width = hessianXX.width; final int height = hessianXX.height; if( featureIntensity == null ) { featureIntensity = new GrayF32(width,height); } for( int y = 0; y < height; y++ ) { int indexXX = hessianXX.startIndex + y*hessianXX.stride; int indexYY = hessianYY.startIndex + y*hessianYY.stride; int indexInten = featureIntensity.startIndex + y*featureIntensity.stride; for( int x = 0; x < width; x++ ) { float dxx = hessianXX.data[indexXX++]; float dyy = hessianYY.data[indexYY++]; featureIntensity.data[indexInten++] = dxx + dyy; } } }
/** * Specifies size of input image and predeclares data structures */ public void initializeImages( int width , int height ) { if( graySrc != null && graySrc.width == width && graySrc.height == height ) return; graySrc = new GrayF32(width,height); grayDst = new GrayF32(width,height); bitmapSrc = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); bitmapDst = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); storage = ConvertBitmap.declareStorage(bitmapSrc, storage); SEPARATION = (int)(width*0.05); renderWidth = width*2 + SEPARATION; renderHeight = height; }
public GrayF32 getGrayF32() { GrayF32 gray = new GrayF32(bufferred.getWidth(),bufferred.getHeight()); ConvertBufferedImage.convertFrom(bufferred,gray); return gray; }
@Override public void initialize(int imageWidth, int imageHeight, int sensorOrientation) { grayF = new GrayF32(imageWidth,imageHeight); transform = new InterleavedF32(imageWidth,imageHeight,2); }
protected void init(DetectorFiducialCalibration detector, double width, Class<T> imageType) { this.detector = detector; this.type = ImageType.single(imageType); this.converted = new GrayF32(1,1); this.width = width; List<Point2D_F64> layout = detector.getLayout(); points2D3D = new ArrayList<>(); for (int i = 0; i < layout.size(); i++) { Point2D_F64 p2 = layout.get(i); Point2D3D p = new Point2D3D(); p.location.set(p2.x,p2.y,0); points2D3D.add(p); } }
public void process( final BufferedImage input ) { setInputImage(input); this.input = input; workImage = ConvertBufferedImage.convertFromSingle(input, null, imageType); scaledIntensity = new GrayF32(workImage.width,workImage.height); SwingUtilities.invokeLater(new Runnable() { public void run() { setPreferredSize(new Dimension(input.getWidth(),input.getHeight())); processedImage = true; }}); doRefreshAll(); }
/** * 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 GrayF32 average( Planar<GrayF32> input , GrayF32 output ) { if (output == null) { output = new GrayF32(input.width, input.height); } else { output.reshape(input.width,input.height); } ImplConvertPlanarToGray.average(input, output); return output; }
/** * Converts a {@link InterleavedF32} into a {@link GrayF32} 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 GrayF32 average( InterleavedF32 input , GrayF32 output ) { if (output == null) { output = new GrayF32(input.width, input.height); } else { output.reshape(input.width,input.height); } ConvertInterleavedToSingle.average(input, output); return output; }
public static GrayF32 convertToImage(Kernel2D_F32 kernel ) { int w = kernel.getWidth(); GrayF32 ret = new GrayF32(w,w); for( int i = 0; i < w; i++ ) { for( int j = 0; j < w; j++ ) { ret.set(j,i,kernel.get(j,i)); } } return ret; }
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); }
public static void magnitudeAbs(ImageFlow flowImage, float maxValue, BufferedImage out) { GrayF32 magnitude = new GrayF32(flowImage.width,flowImage.height); for( int y = 0; y < flowImage.height; y++ ) { for( int x = 0; x < flowImage.width; x++ ) { ImageFlow.D f = flowImage.unsafe_get(x,y); if( !f.isValid() ) { out.setRGB(x,y,0xFF); } else { float m = Math.max(Math.abs(f.x),Math.abs(f.y)); magnitude.unsafe_set(x, y, m); } } } PixelMath.multiply(magnitude, 255 / maxValue, magnitude); PixelMath.boundImage(magnitude,0,255); ConvertBufferedImage.convertTo(magnitude,out); }
/** * Constructor which specifies the input image type. * * @param imageType Either {@link GrayU8} or {@link GrayF32} */ public TldVarianceFilter( Class<T> imageType ) { // declare integral images. if(GeneralizedImageOps.isFloatingPoint(imageType) ) { integral = new GrayF32(1,1); integralSq = new GrayF64(1,1); } else { integral = new GrayS32(1,1); integralSq = new GrayS64(1,1); } }
@Override public GrayF32 transform(GrayF32 original, GrayF32 transformed) { if( transformed == null ) { ImageDimension d = UtilWavelet.transformDimension(original,numLevels); transformed = new GrayF32(d.width,d.height); } temp.reshape(transformed.width,transformed.height); copy.reshape(original.width,original.height); copy.setTo(original); WaveletTransformOps.transformN(desc,copy,transformed,temp,numLevels); return transformed; }
@Override public void initialize(int imageWidth, int imageHeight, int sensorOrientation) { intrinsic = lookupIntrinsics(); if( intrinsic == null ) return; DetectDescribePoint<GrayF32, BrightFeature> detDesc = FactoryDetectDescribe.surfFast(null,null,null,GrayF32.class); ScoreAssociation<BrightFeature> score = FactoryAssociation.defaultScore(BrightFeature.class); AssociateDescription<BrightFeature> associate = FactoryAssociation.greedy(score,Double.MAX_VALUE,true); disparity = new DisparityCalculation<>(detDesc, associate, intrinsic); disparityImage = new GrayF32(imageWidth,imageHeight); visualize.initializeImages( imageWidth, imageHeight ); disparity.init(imageWidth,imageHeight); }
private double computeEdgeMSE(GrayF32 imageInv) { GrayF32 edge = new GrayF32(imageInv.width,imageInv.height); LaplacianEdge.process(image,edge); PixelMath.abs(edge,edge); float max = ImageStatistics.maxAbs(edge); PixelMath.divide(edge,max,edge); float total = ImageStatistics.sum(edge); double error = 0; for( int y = 0; y < image.height; y++ ) { for( int x = 0; x < image.width; x++ ) { double w = edge.get(x,y)/total; double e = (image.get(x,y)-imageInv.get(x,y)); error += (e*e)*w; } } return error; }