code
stringlengths
73
34.1k
label
stringclasses
1 value
public static <T extends ImageBase<T>> void boundImage(T input , double min , double max ) { if( input instanceof ImageGray ) { if (GrayU8.class == input.getClass()) { PixelMath.boundImage((GrayU8) input, (int) min, (int) max); } else if (GrayS8.class == input.getClass()) { PixelMath.boundImage((GrayS8)...
java
private void updateTargetDescription() { if( targetPt != null ) { TupleDesc feature = describe.createDescription(); describe.process(targetPt.x,targetPt.y,targetOrientation,targetRadius,feature); tuplePanel.setDescription(feature); } else { tuplePanel.setDescription(null); } tuplePanel.repaint(); }
java
public static DMatrixRMaj inducedHomography13( TrifocalTensor tensor , Vector3D_F64 line2 , DMatrixRMaj output ) { if( output == null ) output = new DMatrixRMaj(3,3); DMatrixRMaj T = tensor.T1; // H(:,0) = transpose(T1)*line output.data[0] = T.data[0]*line2.x + T.data[3]*line2...
java
public static DMatrixRMaj inducedHomography12( TrifocalTensor tensor , Vector3D_F64 line3 , DMatrixRMaj output ) { if( output == null ) output = new DMatrixRMaj(3,3); // H(:,0) = T1*line DMatrixRMaj T = tensor.T1; output.data[0] = T.data[0]*line3.x + T.data[1]*line3.y + T.data[...
java
public static DMatrixRMaj homographyStereo3Pts( DMatrixRMaj F , AssociatedPair p1, AssociatedPair p2, AssociatedPair p3) { HomographyInducedStereo3Pts alg = new HomographyInducedStereo3Pts(); alg.setFundamental(F,null); if( !alg.process(p1,p2,p3) ) return null; return alg.getHomography(); }
java
public static DMatrixRMaj homographyStereoLinePt( DMatrixRMaj F , PairLineNorm line, AssociatedPair point) { HomographyInducedStereoLinePt alg = new HomographyInducedStereoLinePt(); alg.setFundamental(F,null); alg.process(line,point); return alg.getHomography(); }
java
public static DMatrixRMaj homographyStereo2Lines( DMatrixRMaj F , PairLineNorm line0, PairLineNorm line1) { HomographyInducedStereo2Line alg = new HomographyInducedStereo2Line(); alg.setFundamental(F,null); if( !alg.process(line0,line1) ) return null; return alg.getHomography(); }
java
public static DMatrixRMaj createFundamental(DMatrixRMaj E, CameraPinhole intrinsic ) { DMatrixRMaj K = PerspectiveOps.pinholeToMatrix(intrinsic,(DMatrixRMaj)null); return createFundamental(E,K); }
java
public static void projectiveToMetric( DMatrixRMaj cameraMatrix , DMatrixRMaj H , Se3_F64 worldToView , DMatrixRMaj K ) { DMatrixRMaj tmp = new DMatrixRMaj(3,4); CommonOps_DDRM.mult(cameraMatrix,H,tmp); MultiViewOps.decomposeMetricCamera(tmp,K,worldToView); }
java
public static void projectiveToMetricKnownK( DMatrixRMaj cameraMatrix , DMatrixRMaj H , DMatrixRMaj K, Se3_F64 worldToView ) { DMatrixRMaj tmp = new DMatrixRMaj(3,4); CommonOps_DDRM.mult(cameraMatrix,H,tmp); DMatrixRMaj K_inv = new DMatrixRMaj(3,3); CommonOps_DDRM.invert(K,K_inv); ...
java
public static void rectifyHToAbsoluteQuadratic(DMatrixRMaj H , DMatrixRMaj Q ) { int indexQ = 0; for (int rowA = 0; rowA < 4; rowA++) { for (int colB = 0; colB < 4; colB++) { int indexA = rowA*4; int indexB = colB*4; double sum = 0; for (int i = 0; i < 3; i++) { // sum += H.get(rowA,i)*H.get...
java
public static void intrinsicFromAbsoluteQuadratic( DMatrixRMaj Q , DMatrixRMaj P , CameraPinhole intrinsic ) { DMatrixRMaj tmp = new DMatrixRMaj(3,4); DMatrixRMaj tmp2 = new DMatrixRMaj(3,3); CommonOps_DDRM.mult(P,Q,tmp); CommonOps_DDRM.multTransB(tmp,P,tmp2); decomposeDiac(tmp2,intrinsic); }
java
public static Tuple2<List<Point2D_F64>,List<Point2D_F64>> split2( List<AssociatedPair> input ) { List<Point2D_F64> list1 = new ArrayList<>(); List<Point2D_F64> list2 = new ArrayList<>(); for (int i = 0; i < input.size(); i++) { list1.add( input.get(i).p1 ); list2.add( input.get(i).p2 ); } return new ...
java
public static Tuple3<List<Point2D_F64>,List<Point2D_F64>,List<Point2D_F64>> split3(List<AssociatedTriple> input ) { List<Point2D_F64> list1 = new ArrayList<>(); List<Point2D_F64> list2 = new ArrayList<>(); List<Point2D_F64> list3 = new ArrayList<>(); for (int i = 0; i < input.size(); i++) { list1.add( inpu...
java
protected void performShrinkage( I transform , int numLevels ) { // step through each layer in the pyramid. for( int i = 0; i < numLevels; i++ ) { int w = transform.width; int h = transform.height; int ww = w/2; int hh = h/2; Number threshold; I subband; // HL subband = transform.subimage(...
java
@Override public void denoise(GrayF32 transform , int numLevels ) { int scale = UtilWavelet.computeScale(numLevels); final int h = transform.height; final int w = transform.width; // width and height of scaling image final int innerWidth = w/scale; final int innerHeight = h/scale; GrayF32 subbandHH = ...
java
public static WaveletDescription<WlCoef_F32> generate_F32( int I ) { if( I != 6 ) { throw new IllegalArgumentException("Only 6 is currently supported"); } WlCoef_F32 coef = new WlCoef_F32(); coef.offsetScaling = -2; coef.offsetWavelet = -2; coef.scaling = new float[6]; coef.wavelet = new float[6]; ...
java
public static FitData<EllipseRotated_F64> fitEllipse_F64( List<Point2D_F64> points, int iterations , boolean computeError , FitData<EllipseRotated_F64> outputStorage ) { if( outputStorage == null ) { outputStorage = new FitData<>(new EllipseRotated_F64()); } // Compute the o...
java
public static List<Point2D_F64> convert_I32_F64(List<Point2D_I32> points) { return convert_I32_F64(points,null).toList(); }
java
public static FitData<Circle2D_F64> averageCircle_I32(List<Point2D_I32> points, GrowQueue_F64 optional, FitData<Circle2D_F64> outputStorage) { if( outputStorage == null ) { outputStorage = new FitData<>(new Circle2D_F64()); } if( optional == null ) { optional = new GrowQueue_F64(); } Ci...
java
public void fixate() { ransac = FactoryMultiViewRobust.trifocalRansac(configTriRansac,configError,configRansac); sba = FactoryMultiView.bundleSparseProjective(configSBA); }
java
boolean selectInitialTriplet( View seed , GrowQueue_I32 motions , int selected[] ) { double bestScore = 0; for (int i = 0; i < motions.size; i++) { View viewB = seed.connections.get(i).other(seed); for (int j = i+1; j < motions.size; j++) { View viewC = seed.connections.get(j).other(seed); double s ...
java
private void triangulateFeatures(List<AssociatedTriple> inliers, DMatrixRMaj P1, DMatrixRMaj P2, DMatrixRMaj P3) { List<DMatrixRMaj> cameraMatrices = new ArrayList<>(); cameraMatrices.add(P1); cameraMatrices.add(P2); cameraMatrices.add(P3); // need elements to be non-empty so that it can use set()....
java
private void initializeProjective3(FastQueue<AssociatedTriple> associated , FastQueue<AssociatedTripleIndex> associatedIdx , int totalViews, View viewA , View viewB , View viewC , int idxViewB , int idxViewC ) { ransac.process(associated.toList()); List<AssociatedTri...
java
boolean findRemainingCameraMatrices(LookupSimilarImages db, View seed, GrowQueue_I32 motions) { points3D.reset(); // points in 3D for (int i = 0; i < structure.points.length; i++) { structure.points[i].get(points3D.grow()); } // contains associated pairs of pixel observations // save a call to db by using ...
java
private boolean computeCameraMatrix(View seed, Motion edge, FastQueue<Point2D_F64> featsB, DMatrixRMaj cameraMatrix ) { boolean seedSrc = edge.src == seed; int matched = 0; for (int i = 0; i < edge.inliers.size; i++) { // need to go from i to index of detected features in view 'seed' to index index of feature...
java
private SceneObservations createObservationsForBundleAdjustment(LookupSimilarImages db, View seed, GrowQueue_I32 motions) { // seed view + the motions SceneObservations observations = new SceneObservations(motions.size+1); // Observations for the seed view are a special case SceneObservations.View obsView = ob...
java
private boolean refineWithBundleAdjustment(SceneObservations observations) { if( scaleSBA ) { scaler.applyScale(structure,observations); } sba.setVerbose(verbose,verboseLevel); sba.setParameters(structure,observations); sba.configure(converge.ftol,converge.gtol,converge.maxIterations); if( !sba.optimiz...
java
public static void nv21ToBoof(byte[] data, int width, int height, ImageBase output) { if( output instanceof Planar) { Planar ms = (Planar) output; if (ms.getBandType() == GrayU8.class) { ConvertNV21.nv21TPlanarRgb_U8(data, width, height, ms); } else if (ms.getBandType() == GrayF32.class) { ConvertN...
java
public static <T extends ImageGray<T>> T nv21ToGray( byte[] data , int width , int height , T output , Class<T> outputType ) { if( outputType == GrayU8.class ) { return (T)nv21ToGray(data,width,height,(GrayU8)output); } else if( outputType == GrayF32.class ) { return (T)nv21ToGray(data,width,height,(G...
java
public static GrayU8 nv21ToGray(byte[] data , int width , int height , GrayU8 output ) { if( output != null ) { output.reshape(width,height); } else { output = new GrayU8(width,height); } if(BoofConcurrency.USE_CONCURRENT ) { ImplConvertNV21_MT.nv21ToGray(data, output); } else { ImplConvertNV21.n...
java
public void generate( long value , int gridWidth ) { renderer.init(); drawBorder(); double whiteBorder = whiteBorderDoc /markerWidth; double X0 = whiteBorder+blackBorder; double Y0 = whiteBorder+blackBorder; double bw = (1.0-2*X0)/gridWidth; // Draw the black corner used to ID the orientation square...
java
public void setConfiguration( Se3_F64 planeToCamera , CameraPinholeBrown intrinsic ) { this.planeToCamera = planeToCamera; normToPixel = LensDistortionFactory.narrow(intrinsic).distort_F64(false, true); pixelToNorm = LensDistortionFactory.narrow(intrinsic).undistort_F64(true, false); planeToCamera.i...
java
public void setIntrinsic(CameraPinholeBrown intrinsic ) { normToPixel = LensDistortionFactory.narrow(intrinsic).distort_F64(false, true); pixelToNorm = LensDistortionFactory.narrow(intrinsic).undistort_F64(true, false); }
java
public void setPlaneToCamera(Se3_F64 planeToCamera, boolean computeInverse ) { this.planeToCamera = planeToCamera; if( computeInverse ) planeToCamera.invert(cameraToPlane); }
java
public boolean planeToPixel( double pointX , double pointY , Point2D_F64 pixel ) { // convert it into a 3D coordinate and transform into camera reference frame plain3D.set(-pointY, 0, pointX); SePointOps_F64.transform(planeToCamera, plain3D, camera3D); // if it's behind the camera it can't be seen if( camera...
java
public boolean planeToNormalized( double pointX , double pointY , Point2D_F64 normalized ) { // convert it into a 3D coordinate and transform into camera reference frame plain3D.set(-pointY, 0, pointX); SePointOps_F64.transform(planeToCamera, plain3D, camera3D); // if it's behind the camera it can't be seen ...
java
public void convert( FeatureGraph2D graph ) { graph.nodes.resize(corners.size); graph.reset(); for (int i = 0; i < corners.size; i++) { Node c = corners.get(i); FeatureGraph2D.Node n = graph.nodes.grow(); n.reset(); n.set(c.x,c.y); n.index = c.index; } for (int i = 0; i < corners.size; i++) { ...
java
public boolean process( I frame ) { keyFrame = false; // update the feature tracker tracker.process(frame); totalFramesProcessed++; List<PointTrack> tracks = tracker.getActiveTracks(null); if( tracks.size() == 0 ) return false; List<AssociatedPair> pairs = new ArrayList<>(); for( PointTrack t : ...
java
public void changeKeyFrame() { // drop all inactive tracks since their location is unknown in the current frame List<PointTrack> inactive = tracker.getInactiveTracks(null); for( PointTrack l : inactive ) { tracker.dropTrack(l); } // set the keyframe for active tracks as their current location List<Point...
java
public static double autoScale( List<Point3D_F64> cloud , double target ) { Point3D_F64 mean = new Point3D_F64(); Point3D_F64 stdev = new Point3D_F64(); statistics(cloud, mean, stdev); double scale = target/(Math.max(Math.max(stdev.x,stdev.y),stdev.z)); int N = cloud.size(); for (int i = 0; i < N ; i++...
java
public static void statistics( List<Point3D_F64> cloud , Point3D_F64 mean , Point3D_F64 stdev ) { final int N = cloud.size(); for (int i = 0; i < N; i++) { Point3D_F64 p = cloud.get(i); mean.x += p.x / N; mean.y += p.y / N; mean.z += p.z / N; } for (int i = 0; i < N; i++) { Point3D_F64 p = cloud...
java
public static void prune(List<Point3D_F64> cloud , int minNeighbors , double radius ) { if( minNeighbors < 0 ) throw new IllegalArgumentException("minNeighbors must be >= 0"); NearestNeighbor<Point3D_F64> nn = FactoryNearestNeighbor.kdtree(new KdTreePoint3D_F64() ); NearestNeighbor.Search<Point3D_F64> search =...
java
public static void computeNormalizationLL(List<List<Point2D_F64>> points, NormalizationPoint2D normalize ) { double meanX = 0; double meanY = 0; int count = 0; for (int i = 0; i < points.size(); i++) { List<Point2D_F64> l = points.get(i); for (int j = 0; j < l.size(); j++) { Point2D_F64 p = l.get(j...
java
public static void convertFile( File original ) throws IOException { File outputFile = determineClassName(original); String classNameOld = className(original); String classNameNew = className(outputFile); // Read the file and split it up into lines List<String> inputLines = FileUtils.readLines(original,"UTF...
java
private static File determineClassName( File original ) throws IOException { String text = FileUtils.readFileToString(original, "UTF-8"); if(!text.contains("//CONCURRENT")) throw new IOException("Not a concurrent file"); String pattern = "//CONCURRENT_CLASS_NAME "; int where = text.indexOf(pattern); if( ...
java
@Override public void initialize(int width, int height) { // see if it has already been initialized if( bottomWidth == width && bottomHeight == height ) return; this.bottomWidth = width; this.bottomHeight = height; layers = imageType.createArray(getNumLayers()); double scaleFactor = getScale(0); if ...
java
protected void checkScales() { if( getScale(0) < 0 ) { throw new IllegalArgumentException("The first layer must be more than zero."); } double prevScale = 0; for( int i = 0; i < getNumLayers(); i++ ) { double s = getScale(i); if( s < prevScale ) throw new IllegalArgumentException("Higher layers mu...
java
static boolean checkGridSize(List<List<NodeInfo>> grid , int clusterSize ) { int total = 0; int expected = grid.get(0).size(); for (int i = 0; i < grid.size(); i++) { if( expected != grid.get(i).size() ) return false; total += grid.get(i).size(); } return total == clusterSize; }
java
public double depthNView( List<Point2D_F64> obs , List<Se3_F64> motion ) { double top = 0, bottom = 0; Point2D_F64 a = obs.get(0); for( int i = 1; i < obs.size(); i++ ) { Se3_F64 se = motion.get(i-1); Point2D_F64 b = obs.get(i); GeometryMath_F64.multCrossA(b, se.getR(), temp0); GeometryMa...
java
public double depth2View( Point2D_F64 a , Point2D_F64 b , Se3_F64 fromAtoB ) { DMatrixRMaj R = fromAtoB.getR(); Vector3D_F64 T = fromAtoB.getT(); GeometryMath_F64.multCrossA(b, R, temp0); GeometryMath_F64.mult(temp0,a,temp1); GeometryMath_F64.cross(b, T, temp2); return -(temp2.x+temp2.y+temp2.z)/(temp1....
java
public void initialize( int numFeatures , int numViews ) { depths.reshape(numViews,numFeatures); pixels.reshape(numViews*2,numFeatures); pixelScale = 0; }
java
public void setPixels(int view , List<Point2D_F64> pixelsInView ) { if( pixelsInView.size() != pixels.numCols ) throw new IllegalArgumentException("Pixel count must be constant and match "+pixels.numCols); int row = view*2; for (int i = 0; i < pixelsInView.size(); i++) { Point2D_F64 p = pixelsInView.get(i)...
java
public void setDepths( int view , double featureDepths[] ) { if( featureDepths.length < depths.numCols ) throw new IllegalArgumentException("Pixel count must be constant and match "+pixels.numCols); int N = depths.numCols; for (int i = 0; i < N; i++) { depths.set(view,i, featureDepths[i]); } }
java
public void setDepthsFrom3D(int view , List<Point3D_F64> locations ) { if( locations.size() != pixels.numCols ) throw new IllegalArgumentException("Pixel count must be constant and match "+pixels.numCols); int N = depths.numCols; for (int i = 0; i < N; i++) { depths.set(view,i, locations.get(i).z ); } }
java
public boolean process() { int numViews = depths.numRows; int numFeatures = depths.numCols; P.reshape(3*numViews,4); X.reshape(4,numFeatures); A.reshape(numViews*3,numFeatures); B.reshape(numViews*3,numFeatures); // Scale depths so that they are close to unity normalizeDepths(depths); // Compute th...
java
public void getCameraMatrix(int view , DMatrixRMaj cameraMatrix ) { cameraMatrix.reshape(3,4); CommonOps_DDRM.extract(P,view*3,0,cameraMatrix); for (int col = 0; col < 4; col++) { cameraMatrix.data[cameraMatrix.getIndex(0,col)] *= pixelScale; cameraMatrix.data[cameraMatrix.getIndex(1,col)] *= pixelScale; ...
java
public void getFeature3D( int feature , Point4D_F64 out ) { out.x = X.get(0,feature); out.y = X.get(1,feature); out.z = X.get(2,feature); out.w = X.get(3,feature); }
java
protected void computeScoreFive( int top[] , int middle[] , int bottom[] , int score[] , int width ) { // disparity as the outer loop to maximize common elements in inner loops, reducing redundant calculations for( int d = minDisparity; d < maxDisparity; d++ ) { // take in account the different in image border...
java
public void setTrifocal(TrifocalTensor tensor ) { this.tensor = tensor; extract.setTensor(tensor); extract.extractFundmental(F21,F31); }
java
public void transfer_1_to_3(double x1 , double y1 , double x2 , double y2 , Point3D_F64 p3) { // Adjust the observations so that they lie on the epipolar lines exactly adjuster.process(F21,x1,y1,x2,y2,pa,pb); GeometryMath_F64.mult(F21,pa,la); // line through pb and perpendicular to la l.x = la.y; ...
java
public void transfer_1_to_2(double x1 , double y1 , double x3 , double y3 , Point3D_F64 p2) { // Adjust the observations so that they lie on the epipolar lines exactly adjuster.process(F31,x1,y1,x3,y3,pa,pb); GeometryMath_F64.multTran(F31,pa,la); // line through pb and perpendicular to la l.x = la....
java
@Override public void classify(Planar<GrayF32> image) { DataManipulationOps.imageToTensor(preprocess(image),tensorInput,0); innerProcess(tensorInput); }
java
public static void computeScoreRow(GrayU8 left, GrayU8 right, int row, int[] scores, int minDisparity , int maxDisparity , int regionWidth , int elementScore[] ) { // disparity as the outer loop to maximize common elements in inner loops, reducing redundant calculations for( int d = minDisp...
java
public static void computeScoreRowSad(GrayF32 left, GrayF32 right, int elementMax, int indexLeft, int indexRight, float elementScore[]) { for( int rCol = 0; rCol < elementMax; rCol++ ) { float diff = (left.data[ indexLeft++ ]) - (right.data[ indexRight++ ]); elementScore[rCol] = Math.a...
java
public Se3_F64 estimateOutliers( List<Point2D3D> observations ) { // We can no longer trust that each point is a real observation. Let's use RANSAC to separate the points // You will need to tune the number of iterations and inlier threshold!!! ModelMatcherMultiview<Se3_F64,Point2D3D> ransac = FactoryMultiVi...
java
public void addOutliers( List<Point2D3D> observations , int total ) { int size = observations.size(); for (int i = 0; i < total; i++) { // outliers will be created by adding lots of noise to real observations Point2D3D p = observations.get(rand.nextInt(size)); Point2D3D o = new Point2D3D(); o.observa...
java
@Override public void loadInputData(String fileName) { Reader r = media.openFile(fileName); List<PathLabel> refs = new ArrayList<>(); try { BufferedReader reader = new BufferedReader(r); String line; while( (line = reader.readLine()) != null ) { String[]z = line.split(":"); String[] names = n...
java
public void addToToolbar( JComponent comp ) { toolbar.add(comp,1+algBoxes.length); toolbar.revalidate(); addedComponents.add(comp); }
java
public void setMainGUI( final Component gui ) { postAlgorithmEvents = true; this.gui = gui; SwingUtilities.invokeLater(new Runnable() { public void run() { add(gui,BorderLayout.CENTER); }}); }
java
public void setInputImage( BufferedImage image ) { inputImage = image; SwingUtilities.invokeLater(new Runnable() { public void run() { if( inputImage == null ) { originalCheck.setEnabled(false); } else { originalCheck.setEnabled(true); origPanel.setImage(inputImage); origPanel.setPref...
java
public void setInputList(final List<PathLabel> inputRefs) { this.inputRefs = inputRefs; SwingUtilities.invokeLater(new Runnable() { public void run() { for( int i = 0; i < inputRefs.size(); i++ ) { imageBox.addItem(inputRefs.get(i).getLabel()); } }}); }
java
protected <T> T getAlgorithmCookie( int indexFamily ) { return (T)algCookies[indexFamily].get( algBoxes[indexFamily].getSelectedIndex() ); }
java
private boolean checkSideSize( Polygon2D_F64 p ) { double max=0,min=Double.MAX_VALUE; for (int i = 0; i < p.size(); i++) { double l = p.getSideLength(i); max = Math.max(max,l); min = Math.min(min,l); } // See if a side is too small to decode if( min < 10 ) return false; // see if it's under e...
java
protected double computeFractionBoundary( float pixelThreshold ) { // TODO ignore outer pixels from this computation. Will require 8 regions (4 corners + top/bottom + left/right) final int w = square.width; int radius = (int) (w * borderWidthFraction); int innerWidth = w-2*radius; int total = w*w - innerWid...
java
private void prepareForOutput(Polygon2D_F64 imageShape, Result result) { // the rotation estimate, apply in counter clockwise direction // since result.rotation is a clockwise rotation in the visual sense, which // is CCW on the grid int rotationCCW = (4-result.rotation)%4; for (int j = 0; j < rotationCCW; j+...
java
public void process( GrayS32 pixelToRegion , GrowQueue_I32 regionMemberCount, FastQueue<float[]> regionColor , FastQueue<Point2D_I32> modeLocation ) { stopRequested = false; initializeMerge(regionMemberCount.size); markMergeRegions(regionColor,modeLocation,pixelToRegion); if( stopRequested...
java
protected void markMergeRegions(FastQueue<float[]> regionColor, FastQueue<Point2D_I32> modeLocation, GrayS32 pixelToRegion ) { for( int targetId = 0; targetId < modeLocation.size &&!stopRequested; targetId++ ) { float[] color = regionColor.get(targetId); Point2D_I32 location = modeLocation.g...
java
public static void convertToBoof(Picture input, ImageBase output) { if( input.getColor() == ColorSpace.RGB ) { ImplConvertJCodecPicture.RGB_to_PLU8(input, (Planar) output); } else if( input.getColor() == ColorSpace.YUV420 ) { if( output instanceof Planar) { Planar ms = (Planar)output; if( ms.getImageT...
java
public boolean process( DMatrixRMaj R , List<Point3D_F64> worldPts , List<Point2D_F64> observed ) { if( worldPts.size() != observed.size() ) throw new IllegalArgumentException("Number of worldPts and observed must be the same"); if( worldPts.size() < 2 ) throw new IllegalArgumentException("A minimum of two p...
java
public void process( GrayU8 binary ) { found.reset(); labeled.reshape(binary.width, binary.height); contourFinder.process(binary, labeled); List<ContourPacked> blobs = contourFinder.getContours(); for (int i = 0; i < blobs.size(); i++) { ContourPacked c = blobs.get(i); contourFinder.loadContour(c.ext...
java
protected void adjustElipseForBinaryBias( EllipseRotated_F64 ellipse ) { ellipse.center.x += 0.5; ellipse.center.y += 0.5; ellipse.a += 0.5; ellipse.b += 0.5; }
java
void undistortContour(List<Point2D_I32> external, FastQueue<Point2D_F64> pointsF ) { for (int j = 0; j < external.size(); j++) { Point2D_I32 p = external.get(j); if( distToUndist != null ) { distToUndist.compute(p.x,p.y,distortedPoint); pointsF.grow().set( distortedPoint.x , distortedPoint.y ); } el...
java
boolean isApproximatelyElliptical(EllipseRotated_F64 ellipse , List<Point2D_F64> points , int maxSamples ) { closestPoint.setEllipse(ellipse); double maxDistance2 = maxDistanceFromEllipse*maxDistanceFromEllipse; if( points.size() <= maxSamples ) { for( int i = 0; i < points.size(); i++ ) { Point2D_F64 p...
java
@Override public boolean filterPixelPolygon(Polygon2D_F64 undistorted , Polygon2D_F64 distorted, GrowQueue_B touches, boolean touchesBorder) { if( touchesBorder ) { if( distorted.size() < 3) return false; int totalRegular = distorted.size(); for (int i = 0; i < distorted.size(); i++) { i...
java
public Frame getFrame(BufferedImage image, double gamma, boolean flipChannels) { if (image == null) { return null; } SampleModel sm = image.getSampleModel(); int depth = 0, numChannels = sm.getNumBands(); switch (image.getType()) { case BufferedImage.TYPE_INT_RGB: case BufferedImage.TYPE_INT_ARGB: ...
java
public static int multiply( int x , int y , int primitive , int domain ) { int r = 0; while( y > 0 ) { if( (y&1) != 0 ) { r = r ^ x; } y = y >> 1; x = x << 1; if( x >= domain) { x ^= primitive; } } return r; }
java
private static boolean isClockWise( Grid g ) { EllipseRotated_F64 v00 = g.get(0,0); EllipseRotated_F64 v02 = g.columns<3?g.get(1,1):g.get(0,2); EllipseRotated_F64 v20 = g.rows<3?g.get(1,1):g.get(2,0); double a_x = v02.center.x - v00.center.x; double a_y = v02.center.y - v00.center.y; double b_x = v20.cent...
java
public FDistort init(ImageBase input, ImageBase output) { this.input = input; this.output = output; inputType = input.getImageType(); interp(InterpolationType.BILINEAR); border(0); cached = false; distorter = null; outputToInput = null; return this; }
java
public FDistort setRefs( ImageBase input, ImageBase output ) { this.input = input; this.output = output; inputType = input.getImageType(); return this; }
java
public FDistort input( ImageBase input ) { if( this.input == null || this.input.width != input.width || this.input.height != input.height ) { distorter = null; } this.input = input; inputType = input.getImageType(); return this; }
java
public FDistort output( ImageBase output ) { if( this.output == null || this.output.width != output.width || this.output.height != output.height ) { distorter = null; } this.output = output; return this; }
java
public FDistort border( BorderType type ) { if( borderType == type ) return this; borderType = type; return border(FactoryImageBorder.generic(type, inputType)); }
java
public FDistort border( double value ) { // to recycle here the value also needs to be saved // if( borderType == BorderType.VALUE ) // return this; borderType = BorderType.ZERO; return border(FactoryImageBorder.genericValue(value, inputType)); }
java
public FDistort interp(InterpolationType type) { distorter = null; this.interp = FactoryInterpolation.createPixel(0, 255, type, BorderType.EXTENDED, inputType); return this; }
java
public FDistort affine(double a11, double a12, double a21, double a22, double dx, double dy) { PixelTransformAffine_F32 transform; if( outputToInput != null && outputToInput instanceof PixelTransformAffine_F32 ) { transform = (PixelTransformAffine_F32)outputToInput; } else { transform = new Pixel...
java
public FDistort rotate( double angleInputToOutput ) { PixelTransform<Point2D_F32> outputToInput = DistortSupport.transformRotate(input.width/2,input.height/2, output.width/2,output.height/2,(float)angleInputToOutput); return transform(outputToInput); }
java
public void apply() { // see if the distortion class needs to be created again if( distorter == null ) { Class typeOut = output.getImageType().getImageClass(); switch( input.getImageType().getFamily() ) { case GRAY: distorter = FactoryDistort.distortSB(cached, (InterpolatePixelS)interp, typeOut); ...
java
public boolean process( DMatrixRMaj P ) { if( !svd.decompose(P) ) return false; svd.getU(Ut,true); svd.getV(V,false); double sv[] = svd.getSingularValues(); SingularOps_DDRM.descendingOrder(Ut,true,sv,3,V,false); // compute W+, which is transposed and non-negative inverted for (int i = 0; i < 3; i++...
java
public void computeH( DMatrixRMaj H ) { H.reshape(4,4); CommonOps_DDRM.insert(PA,H,0,0); for (int i = 0; i < 4; i++) { H.unsafe_set(i,3,ns.data[i]); } }
java