code
stringlengths
73
34.1k
label
stringclasses
1 value
public static int downSampleSize( int length , int squareWidth ) { int ret = length/squareWidth; if( length%squareWidth != 0 ) ret++; return ret; }
java
public static void reshapeDown(ImageBase image, int inputWidth, int inputHeight, int squareWidth) { int w = downSampleSize(inputWidth,squareWidth); int h = downSampleSize(inputHeight,squareWidth); image.reshape(w,h); }
java
public static <T extends ImageGray<T>> void down(Planar<T> input , int sampleWidth , Planar<T> output ) { for( int band = 0; band < input.getNumBands(); band++ ) { down(input.getBand(band), sampleWidth, output.getBand(band)); } }
java
public void setCamera1( double fx , double fy , double skew , double cx , double cy ) { PerspectiveOps.pinholeToMatrix(fx,fy,skew,cx,cy,K1); }
java
public void setCamera2( double fx , double fy , double skew , double cx , double cy ) { PerspectiveOps.pinholeToMatrix(fx,fy,skew,cx,cy,K2); PerspectiveOps.invertPinhole(K2,K2_inv); }
java
public boolean estimatePlaneAtInfinity( DMatrixRMaj P2 , Vector3D_F64 v ) { PerspectiveOps.projectionSplit(P2,Q2,q2); // inv(K2)*(Q2*K1 + q2*v') CommonOps_DDF3.mult(K2_inv,q2,t2); CommonOps_DDF3.mult(K2_inv,Q2,tmpA); CommonOps_DDF3.mult(tmpA,K1,tmpB); // Find the rotation matrix R*t2 = [||t2||,0,0]^T co...
java
public void process(SimpleImageSequence<T> sequence) { // Figure out how large the GUI window should be T frame = sequence.next(); gui.setPreferredSize(new Dimension(frame.getWidth(),frame.getHeight())); ShowImages.showWindow(gui,"KTL Tracker", true); // process each frame in the image sequence while( seq...
java
private void updateGUI(SimpleImageSequence<T> sequence) { BufferedImage orig = sequence.getGuiImage(); Graphics2D g2 = orig.createGraphics(); // draw tracks with semi-unique colors so you can track individual points with your eyes for( PointTrack p : tracker.getActiveTracks(null) ) { int red = (int)(2.5*(p....
java
public void createSURF() { ConfigFastHessian configDetector = new ConfigFastHessian(); configDetector.maxFeaturesPerScale = 250; configDetector.extractRadius = 3; configDetector.initialSampleSize = 2; tracker = FactoryPointTracker.dda_FH_SURF_Fast(configDetector, null, null, imageType); }
java
public void configure( int width , int height , float vfov ) { declareVectors( width, height ); float r = (float)Math.tan(vfov/2.0f); for (int pixelY = 0; pixelY < height; pixelY++) { float z = 2*r*pixelY/(height-1) - r; for (int pixelX = 0; pixelX < width; pixelX++) { float theta = GrlConstants.F_PI2...
java
public boolean process( T image ) { configureContourDetector(image); binary.reshape(image.width,image.height); inputToBinary.process(image,binary); detectorSquare.process(image, binary); detectorSquare.refineAll(); detectorSquare.getPolygons(found,null); clusters = s2c.process(found); c2g.process(clu...
java
void extractCalibrationPoints(SquareGrid grid) { calibrationPoints.clear(); for (int row = 0; row < grid.rows; row++) { row0.clear(); row1.clear(); for (int col = 0; col < grid.columns; col++) { Polygon2D_F64 square = grid.get(row,col).square; row0.add(square.get(0)); row0.add(square.get(1));...
java
public static <T extends ImageGray<T>> SparseScaleGradient<T,?> createGradient( boolean useHaar , Class<T> imageType ) { if( useHaar ) return FactorySparseIntegralFilters.haar(imageType); else return FactorySparseIntegralFilters.gradient(imageType); }
java
public static <T extends ImageGray<T>> boolean isInside( T ii , double X , double Y , int radiusRegions , int kernelSize , double scale, double c , double s ) { int c_x = (int)Math.round(X); int c_y = (int)Math.round(Y); kernelSize = (int)Math.ceil(kernelSize*scale); int kernelRadius = kernelSize/2+...
java
public static double rotatedWidth( double width , double c , double s ) { return Math.abs(c)*width + Math.abs(s)*width; }
java
public void assignIDsToRigidPoints() { // return if it has already been assigned if( lookupRigid != null ) return; // Assign a unique ID to each point belonging to a rigid object // at the same time create a look up table that allows for the object that a point belongs to be quickly found lookupRigid = new...
java
public void setCamera(int which , boolean fixed , BundleAdjustmentCamera model ) { cameras[which].known = fixed; cameras[which].model = model; }
java
public void setRigid( int which , boolean fixed , Se3_F64 worldToObject , int totalPoints ) { Rigid r = rigids[which] = new Rigid(); r.known = fixed; r.objectToWorld.set(worldToObject); r.points = new Point[totalPoints]; for (int i = 0; i < totalPoints; i++) { r.points[i] = new Point(pointSize); } }
java
public void connectViewToCamera( int viewIndex , int cameraIndex ) { if( views[viewIndex].camera != -1 ) throw new RuntimeException("View has already been assigned a camera"); views[viewIndex].camera = cameraIndex; }
java
public int getUnknownCameraCount() { int total = 0; for (int i = 0; i < cameras.length; i++) { if( !cameras[i].known) { total++; } } return total; }
java
public int getTotalRigidPoints() { if( rigids == null ) return 0; int total = 0; for (int i = 0; i < rigids.length; i++) { total += rigids[i].points.length; } return total; }
java
public static <T extends KernelBase> T random( Class<?> type , int radius , int min , int max , Random rand ) { int width = radius*2+1; return random(type,width,radius,min,max,rand); }
java
public void detect( II integral ) { if( intensity == null ) { intensity = new GrayF32[3]; for( int i = 0; i < intensity.length; i++ ) { intensity[i] = new GrayF32(integral.width,integral.height); } } foundPoints.reset(); // computes feature intensity every 'skip' pixels int skip = initialSampleR...
java
protected void detectOctave( II integral , int skip , int ...featureSize ) { int w = integral.width/skip; int h = integral.height/skip; // resize the output intensity image taking in account subsampling for( int i = 0; i < intensity.length; i++ ) { intensity[i].reshape(w,h); } // compute feature inten...
java
protected static boolean checkMax(ImageBorder_F32 inten, float bestScore, int c_x, int c_y) { for( int y = c_y -1; y <= c_y+1; y++ ) { for( int x = c_x-1; x <= c_x+1; x++ ) { if( inten.get(x,y) >= bestScore ) { return false; } } } return true; }
java
public void process(T gray, GrayU8 binary ) { configureContourDetector(gray); recycleData(); positionPatterns.reset(); interpolate.setImage(gray); // detect squares squareDetector.process(gray,binary); long time0 = System.nanoTime(); squaresToPositionList(); long time1 = System.nanoTime(); // Cr...
java
private void createPositionPatternGraph() { // Add items to NN search nn.setPoints((List)positionPatterns.toList(),false); for (int i = 0; i < positionPatterns.size(); i++) { PositionPatternNode f = positionPatterns.get(i); // The QR code version specifies the number of "modules"/blocks across the marker...
java
void considerConnect(SquareNode node0, SquareNode node1) { // Find the side on each line which intersects the line connecting the two centers lineA.a = node0.center; lineA.b = node1.center; int intersection0 = graph.findSideIntersect(node0,lineA,intersection,lineB); connectLine.a.set(intersection); int int...
java
boolean checkPositionPatternAppearance( Polygon2D_F64 square , float grayThreshold ) { return( checkLine(square,grayThreshold,0) || checkLine(square,grayThreshold,1)); }
java
static boolean positionSquareIntensityCheck(float values[] , float threshold ) { if( values[0] > threshold || values[1] < threshold ) return false; if( values[2] > threshold || values[3] > threshold || values[4] > threshold ) return false; if( values[5] < threshold || values[6] > threshold ) return fals...
java
public void process( DMatrixRMaj K1 , Se3_F64 worldToCamera1 , DMatrixRMaj K2 , Se3_F64 worldToCamera2 ) { SimpleMatrix sK1 = SimpleMatrix.wrap(K1); SimpleMatrix sK2 = SimpleMatrix.wrap(K2); SimpleMatrix R1 = SimpleMatrix.wrap(worldToCamera1.getR()); SimpleMatrix R2 = SimpleMatrix.wrap(worldToCamera2.ge...
java
private void selectAxises(SimpleMatrix R1, SimpleMatrix R2, SimpleMatrix c1, SimpleMatrix c2) { // --------- Compute the new x-axis v1.set(c2.get(0) - c1.get(0), c2.get(1) - c1.get(1), c2.get(2) - c1.get(2)); v1.normalize(); // --------- Compute the new y-axis // cross product of old z axis and new x axis ...
java
public boolean process(PairLineNorm line0, PairLineNorm line1) { // Find plane equations of second lines in the first view double a0 = GeometryMath_F64.dot(e2,line0.l2); double a1 = GeometryMath_F64.dot(e2,line1.l2); GeometryMath_F64.multTran(A,line0.l2,Al0); GeometryMath_F64.multTran(A,line1.l2,Al1); //...
java
protected int extractNumeral() { int val = 0; final int topLeft = getTotalGridElements() - gridWidth; int shift = 0; // -2 because the top and bottom rows have 2 unusable bits (the first and last) for(int i = 1; i < gridWidth - 1; i++) { final int idx = topLeft + i; val |= classified[idx] << shift; ...
java
private boolean rotateUntilInLowerCorner(Result result) { // sanity check corners. There should only be one exactly one black final int topLeft = getTotalGridElements() - gridWidth; final int topRight = getTotalGridElements() - 1; final int bottomLeft = 0; final int bottomRight = gridWidth - 1; if (classi...
java
protected boolean thresholdBinaryNumber() { int lower = (int) (N * (ambiguityThreshold / 2.0)); int upper = (int) (N * (1 - ambiguityThreshold / 2.0)); final int totalElements = getTotalGridElements(); for (int i = 0; i < totalElements; i++) { if (counts[i] < lower) { classified[i] = 0; } else if (c...
java
protected void findBitCounts(GrayF32 gray , double threshold ) { // compute binary image using an adaptive algorithm to handle shadows ThresholdImageOps.threshold(gray,binaryInner,(float)threshold,true); Arrays.fill(counts, 0); for (int row = 0; row < gridWidth; row++) { int y0 = row * binaryInner.width / g...
java
public void printClassified() { System.out.println(); System.out.println(" "); for (int row = 0; row < gridWidth; row++) { System.out.print(" "); for (int col = 0; col < gridWidth; col++) { System.out.print(classified[row * gridWidth + col] == 1 ? " " : "X"); } System.out.print(" "); Syste...
java
private void initializeStructure(List<AssociatedTriple> listObs, DMatrixRMaj P2, DMatrixRMaj P3) { List<DMatrixRMaj> cameraMatrices = new ArrayList<>(); cameraMatrices.add(P1); cameraMatrices.add(P2); cameraMatrices.add(P3); List<Point2D_F64> triangObs = new ArrayList<>(); triangObs.add(null); triangObs....
java
private boolean backwardsValidation(int indexSrc, int bestIndex) { double bestScoreV = maxError; int bestIndexV = -1; D d_forward = descDst.get(bestIndex); setActiveSource(locationDst.get(bestIndex)); for( int j = 0; j < locationSrc.size(); j++ ) { // compute distance between the two features double ...
java
public static void multiply( GrayU8 input , double value , GrayU8 output ) { output.reshape(input.width,input.height); int columns = input.width; if(BoofConcurrency.USE_CONCURRENT ) { ImplPixelMath_MT.multiplyU_A(input.data,input.startIndex,input.stride,value , output.data,output.startIndex,output.stri...
java
public static void divide( GrayU8 input , double denominator , GrayU8 output ) { output.reshape(input.width,input.height); int columns = input.width; if(BoofConcurrency.USE_CONCURRENT ) { ImplPixelMath_MT.divideU_A(input.data,input.startIndex,input.stride,denominator , output.data,output.startIndex,out...
java
public boolean performTracking( PyramidKltFeature feature ) { KltTrackFault result = tracker.track(feature); if( result != KltTrackFault.SUCCESS ) { return false; } else { tracker.setDescription(feature); return true; } }
java
public static void showDialog(BufferedImage img) { ImageIcon icon = new ImageIcon(); icon.setImage(img); JOptionPane.showMessageDialog(null, icon); }
java
public static ImageGridPanel showGrid( int numColumns , String title , BufferedImage ...images ) { JFrame frame = new JFrame(title); int numRows = images.length/numColumns + images.length%numColumns; ImageGridPanel panel = new ImageGridPanel(numRows,numColumns,images); frame.add(panel, BorderLayout.CENTER); ...
java
public static JFrame setupWindow( final JComponent component , String title, final boolean closeOnExit ) { BoofSwingUtil.checkGuiThread(); final JFrame frame = new JFrame(title); frame.add(component, BorderLayout.CENTER); frame.pack(); frame.setLocationRelativeTo(null); // centers window in the monitor if...
java
public static void applyBoxFilter( GrayF32 input ) { // declare storage GrayF32 boxImage = new GrayF32(input.width, input.height); InterleavedF32 boxTransform = new InterleavedF32(input.width,input.height,2); InterleavedF32 transform = new InterleavedF32(input.width,input.height,2); GrayF32 blurredImage = ne...
java
public static void displayTransform( InterleavedF32 transform , String name ) { // declare storage GrayF32 magnitude = new GrayF32(transform.width,transform.height); GrayF32 phase = new GrayF32(transform.width,transform.height); // Make a copy so that you don't modify the input transform = transform.clone()...
java
public static DMatrixRMaj robustFundamental( List<AssociatedPair> matches , List<AssociatedPair> inliers , double inlierThreshold ) { ConfigRansac configRansac = new ConfigRansac(); configRansac.inlierThreshold = inlierThreshold; configRansac.maxIterations = 1000; ConfigFundamental configFundament...
java
public static DMatrixRMaj simpleFundamental( List<AssociatedPair> matches ) { // Use the 8-point algorithm since it will work with an arbitrary number of points Estimate1ofEpipolar estimateF = FactoryMultiView.fundamental_1(EnumFundamental.LINEAR_8, 0); DMatrixRMaj F = new DMatrixRMaj(3,3); if( !estimateF.proc...
java
public boolean applyErrorCorrection( QrCode qr) { // System.out.println("decoder ver "+qr.version); // System.out.println("decoder mask "+qr.mask); // System.out.println("decoder error "+qr.error); QrCode.VersionInfo info = QrCode.VERSION_INFO[qr.version]; QrCode.BlockInfo block = info.levels.get(qr.error); ...
java
private QrCode.Mode updateModeLogic( QrCode.Mode current , QrCode.Mode candidate ) { if( current == candidate ) return current; else if( current == QrCode.Mode.UNKNOWN ) { return candidate; } else { return QrCode.Mode.MIXED; } }
java
boolean checkPaddingBytes(QrCode qr, int lengthBytes) { boolean a = true; for (int i = lengthBytes; i < qr.corrected.length; i++) { if (a) { if (0b00110111 != (qr.corrected[i] & 0xFF)) return false; } else { if (0b10001000 != (qr.corrected[i] & 0xFF)) { // the pattern starts over at the beg...
java
private int decodeNumeric( QrCode qr , PackedBits8 data, int bitLocation ) { int lengthBits = QrCodeEncoder.getLengthBitsNumeric(qr.version); int length = data.read(bitLocation,lengthBits,true); bitLocation += lengthBits; while( length >= 3 ) { if( data.size < bitLocation+10 ) { qr.failureCause = QrCod...
java
private int decodeAlphanumeric( QrCode qr , PackedBits8 data, int bitLocation ) { int lengthBits = QrCodeEncoder.getLengthBitsAlphanumeric(qr.version); int length = data.read(bitLocation,lengthBits,true); bitLocation += lengthBits; while( length >= 2 ) { if( data.size < bitLocation+11 ) { qr.failureCau...
java
private int decodeByte( QrCode qr , PackedBits8 data, int bitLocation ) { int lengthBits = QrCodeEncoder.getLengthBitsBytes(qr.version); int length = data.read(bitLocation,lengthBits,true); bitLocation += lengthBits; if( length*8 > data.size-bitLocation ) { qr.failureCause = QrCode.Failure.MESSAGE_OVERFLOW...
java
private int decodeKanji( QrCode qr , PackedBits8 data, int bitLocation ) { int lengthBits = QrCodeEncoder.getLengthBitsKanji(qr.version); int length = data.read(bitLocation,lengthBits,true); bitLocation += lengthBits; byte rawdata[] = new byte[ length*2 ]; for (int i = 0; i < length; i++) { if( data.siz...
java
NodeInfo selectSeedCorner() { NodeInfo best = null; double bestScore = 0; double minAngle = Math.PI+0.1; for (int i = 0; i < contour.size; i++) { NodeInfo info = contour.get(i); if( info.angleBetween < minAngle ) continue; Edge middleR = selectClosest(info.right,info,true); if( middleR == nul...
java
static void bottomTwoColumns(NodeInfo first, NodeInfo second, List<NodeInfo> column0, List<NodeInfo> column1) { column0.add(first); column0.add(second); NodeInfo a = selectClosestN(first,second); if( a == null ) { return; } a.marked = true; column1.add(a); NodeInfo b = second; while( true ) { ...
java
static Edge selectClosest( NodeInfo a , NodeInfo b , boolean checkSide ) { double bestScore = Double.MAX_VALUE; Edge bestEdgeA = null; Edge edgeAB = a.findEdge(b); double distAB = a.distance(b); if( edgeAB == null ) { return null;// TODO BUG! FIX! } for (int i = 0; i < a.edges.size; i++) { Edge ...
java
static NodeInfo selectClosestSide( NodeInfo a , NodeInfo b ) { double ratio = 1.7321; NodeInfo best = null; double bestDistance = Double.MAX_VALUE; Edge bestEdgeA = null; Edge bestEdgeB = null; for (int i = 0; i < a.edges.size; i++) { NodeInfo aa = a.edges.get(i).target; if( aa.marked ) continue; ...
java
public static void rgbToYuv( double r , double g , double b , double yuv[] ) { double y = yuv[0] = 0.299*r + 0.587*g + 0.114*b; yuv[1] = 0.492*(b-y); yuv[2] = 0.877*(r-y); }
java
public static void yuvToRgb( double y , double u , double v , double rgb[] ) { rgb[0] = y + 1.13983*v; rgb[1] = y - 0.39465*u - 0.58060*v; rgb[2] = y + 2.032*u; }
java
public boolean process( List<AssociatedTriple> observations , TrifocalTensor solution ) { if( observations.size() < 7 ) throw new IllegalArgumentException( "At least 7 correspondences must be provided. Found "+observations.size()); // compute normalization to reduce numerical errors LowLevelMultiViewOps...
java
protected void createLinearSystem( List<AssociatedTriple> observations ) { int N = observations.size(); A.reshape(4*N,27); A.zero(); for( int i = 0; i < N; i++ ) { AssociatedTriple t = observations.get(i); N1.apply(t.p1,p1_norm); N2.apply(t.p2,p2_norm); N3.apply(t.p3,p3_norm); insert(i,0 , p1...
java
protected boolean solveLinearSystem() { if( !svdNull.decompose(A) ) return false; SingularOps_DDRM.nullVector(svdNull,true,vectorizedSolution); solutionN.convertFrom(vectorizedSolution); return true; }
java
protected void removeNormalization( TrifocalTensor solution ) { DMatrixRMaj N2_inv = N2.matrixInv(); DMatrixRMaj N3_inv = N3.matrixInv(); DMatrixRMaj N1 = this.N1.matrix(); for( int i = 0; i < 3; i++ ) { DMatrixRMaj T = solution.getT(i); for( int j = 0; j < 3; j++ ) { for( int k = 0; k < 3; k++ ) { ...
java
public double computeAverageDerivative(Point2D_F64 a, Point2D_F64 b, double tanX, double tanY) { samplesInside = 0; averageUp = averageDown = 0; for (int i = 0; i < numSamples; i++) { double x = (b.x-a.x)*i/(numSamples-1) + a.x; double y = (b.y-a.y)*i/(numSamples-1) + a.y; double x0 = x+tanX; double...
java
public static void rgbToXyz( int r , int g , int b , double xyz[] ) { srgbToXyz(r/255.0,g/255.0,b/255.0,xyz); }
java
public void configureCamera(CameraPinholeBrown intrinsic , Se3_F64 planeToCamera ) { this.planeToCamera = planeToCamera; if( !selectOverhead.process(intrinsic,planeToCamera) ) throw new IllegalArgumentException("Can't find a reasonable overhead map. Can the camera view the plane?"); overhead.centerX...
java
public Se3_F64 getWorldToCurr3D() { // 2D to 3D coordinates worldToCurr3D.getT().set(-worldToCurr2D.T.y,0,worldToCurr2D.T.x); DMatrixRMaj R = worldToCurr3D.getR(); // set rotation around Y axis. // Transpose the 2D transform since the rotation are pointing in opposite directions R.unsafe_set(0, 0, worldToC...
java
public void process(T gray, GrayU8 binary) { results.reset(); ellipseDetector.process(binary); if( ellipseRefiner != null) ellipseRefiner.setImage(gray); intensityCheck.setImage(gray); List<BinaryEllipseDetectorPixel.Found> found = ellipseDetector.getFound(); for( BinaryEllipseDetectorPixel.Found f : ...
java
public boolean refine( EllipseRotated_F64 ellipse ) { if( autoRefine ) throw new IllegalArgumentException("Autorefine is true, no need to refine again"); if( ellipseRefiner == null ) throw new IllegalArgumentException("Refiner has not been passed in"); if (!ellipseRefiner.process(ellipse,ellipse)) { retu...
java
public static void colorizeSign( GrayF32 input , float maxAbsValue , Bitmap output , byte[] storage ) { shapeShape(input, output); if( storage == null ) storage = declareStorage(output,null); if( maxAbsValue < 0 ) maxAbsValue = ImageStatistics.maxAbs(input); int indexDst = 0; for( int y = 0; y < inp...
java
public static void grayMagnitude(GrayS32 input , int maxAbsValue , Bitmap output , byte[] storage) { shapeShape(input, output); if( storage == null ) storage = declareStorage(output,null); if( maxAbsValue < 0 ) maxAbsValue = ImageStatistics.maxAbs(input); int indexDst = 0; for( int y = 0; y < input....
java
public static void disparity( GrayI disparity, int minValue, int maxValue, int invalidColor, Bitmap output , byte[] storage ) { shapeShape(disparity, output); if( storage == null ) storage = declareStorage(output,null); int range = maxValue - minValue; int indexDst = 0; for (int y = 0; y < di...
java
public static void drawEdgeContours( List<EdgeContour> contours , int color , Bitmap output , byte[] storage ) { if( output.getConfig() != Bitmap.Config.ARGB_8888 ) throw new IllegalArgumentException("Only ARGB_8888 is supported"); if( storage == null ) storage = declareStorage(output,null); else Arrays...
java
public void massage( T input , T output ) { if( clip ) { T inputAdjusted = clipInput(input, output); // configure a simple change in scale for both axises transform.a11 = input.width / (float) output.width; transform.a22 = input.height / (float) output.height; // this change is automatically reflected...
java
T clipInput(T input, T output) { double ratioInput = input.width/(double)input.height; double ratioOutput = output.width/(double)output.height; T a = input; if( ratioInput > ratioOutput ) { // clip the width int width = input.height*output.width/output.height; int x0 = (input.width-width)/2; int x1 =...
java
public static int nextPow2(int x) { if (x < 1) throw new IllegalArgumentException("x must be greater or equal 1"); if ((x & (x - 1)) == 0) { if( x == 1 ) return 2; return x; // x is already a power-of-two number } x |= (x >>> 1); x |= (x >>> 2); x |= (x >>> 4); x |= (x >>> 8); x |= (x >>> 1...
java
public static void checkImageArguments( ImageBase image , ImageInterleaved transform ) { InputSanityCheck.checkSameShape(image,transform); if( 2 != transform.getNumBands() ) throw new IllegalArgumentException("The transform must have two bands"); }
java
public static Se3_F64 estimateCameraMotion(CameraPinholeBrown intrinsic, List<AssociatedPair> matchedNorm, List<AssociatedPair> inliers) { ModelMatcherMultiview<Se3_F64, AssociatedPair> epipolarMotion = FactoryMultiViewRobust.baselineRansac(new ConfigEssential(),new ConfigRansac(200,0.5)); epipol...
java
public static List<AssociatedPair> convertToNormalizedCoordinates(List<AssociatedPair> matchedFeatures, CameraPinholeBrown intrinsic) { Point2Transform2_F64 p_to_n = LensDistortionFactory.narrow(intrinsic).undistort_F64(true, false); List<AssociatedPair> calibratedFeatures = new ArrayList<>(); for (AssociatedP...
java
public static <T extends ImageBase<T>> void rectifyImages(T distortedLeft, T distortedRight, Se3_F64 leftToRight, CameraPinholeBrown intrinsicLeft, CameraPinholeBrown intrinsicRight, T rectifiedLeft, T rectifiedRight, GrayU8 rectifiedMask, DMatrixRMaj rec...
java
public static void drawInliers(BufferedImage left, BufferedImage right, CameraPinholeBrown intrinsic, List<AssociatedPair> normalized) { Point2Transform2_F64 n_to_p = LensDistortionFactory.narrow(intrinsic).distort_F64(false,true); List<AssociatedPair> pixels = new ArrayList<>(); for (AssociatedPair ...
java
public static double euclideanSq(TupleDesc_F64 a, TupleDesc_F64 b) { final int N = a.value.length; double total = 0; for( int i = 0; i < N; i++ ) { double d = a.value[i]-b.value[i]; total += d*d; } return total; }
java
private float iterationSorSafe(GrayF32 image1, int x, int y, int pixelIndex) { float w = SOR_RELAXATION; float uf; float vf; float ui = initFlowX.data[pixelIndex]; float vi = initFlowY.data[pixelIndex]; float u = flowX.data[pixelIndex]; float v = flowY.data[pixelIndex]; float I1 = image1.data[pixelIn...
java
protected static float A_safe( int x , int y , GrayF32 flow ) { float u0 = safe(x-1,y ,flow); float u1 = safe(x+1,y ,flow); float u2 = safe(x ,y-1,flow); float u3 = safe(x ,y+1,flow); float u4 = safe(x-1,y-1,flow); float u5 = safe(x+1,y-1,flow); float u6 = safe(x-1,y+1,flow); float u7 = safe(x+1,y+...
java
protected static float A( int x , int y , GrayF32 flow ) { int index = flow.getIndex(x,y); float u0 = flow.data[index-1]; float u1 = flow.data[index+1]; float u2 = flow.data[index-flow.stride]; float u3 = flow.data[index+flow.stride]; float u4 = flow.data[index-1-flow.stride]; float u5 = flow.data[index...
java
protected static float safe( int x , int y , GrayF32 image ) { if( x < 0 ) x = 0; else if( x >= image.width ) x = image.width-1; if( y < 0 ) y = 0; else if( y >= image.height ) y = image.height-1; return image.unsafe_get(x,y); }
java
public void search( float cx , float cy ) { peakX = cx; peakY = cy; setRegion(cx, cy); for( int i = 0; i < maxIterations; i++ ) { float total = 0; float sumX = 0, sumY = 0; int kernelIndex = 0; // see if it can use fast interpolation otherwise use the safer technique if( interpolate.isInFastBou...
java
protected void setRegion(float cx, float cy) { x0 = cx - radius; y0 = cy - radius; if( x0 < 0 ) { x0 = 0;} else if( x0+width > image.width ) { x0 = image.width-width; } if( y0 < 0 ) { y0 = 0;} else if( y0+width > image.height ) { y0 = image.height-width; } }
java
public void gaussianDerivToDirectDeriv() { T blur = GeneralizedImageOps.createSingleBand(imageType, width, height); T blurDeriv = GeneralizedImageOps.createSingleBand(imageType, width, height); T gaussDeriv = GeneralizedImageOps.createSingleBand(imageType, width, height); BlurStorageFilter<T> funcBlur = Factor...
java
public static PaperSize lookup( String word ) { for( PaperSize paper : values ) { if( paper.name.compareToIgnoreCase(word) == 0 ) { return paper; } } return null; }
java
public static <In extends ImageBase<In>, Out extends ImageBase<Out>, K extends Kernel1D, B extends ImageBorder<In>> void horizontal(K kernel, In input, Out output , B border ) { switch( input.getImageType().getFamily() ) { case GRAY: { if( input instanceof GrayF32) { ConvolveImage.horizontal((Kernel1D_F3...
java
public static <In extends ImageBase<In>, Out extends ImageBase<Out>, K extends Kernel1D> void horizontal(K kernel, In input, Out output ) { switch (input.getImageType().getFamily()) { case GRAY: { if (input instanceof GrayF32) { ConvolveImageNoBorder.horizontal((Kernel1D_F32) kernel, (GrayF32) input, (Gr...
java
public static <In extends ImageBase, Out extends ImageBase, K extends Kernel1D> void horizontalNormalized(K kernel, In input, Out output ) { switch (input.getImageType().getFamily()) { case GRAY: { if (input instanceof GrayF32) { ConvolveImageNormalized.horizontal((Kernel1D_F32) kernel, (GrayF32) input, ...
java
public static <T extends ImageBase<T>, K extends Kernel2D> void convolveNormalized(K kernel, T input, T output ) { switch (input.getImageType().getFamily()) { case GRAY: { if (input instanceof GrayF32) { ConvolveImageNormalized.convolve((Kernel2D_F32) kernel, (GrayF32) input, (GrayF32) output); } els...
java
private void addFirstSegment(int x, int y) { Point2D_I32 p = queuePoints.grow(); p.set(x,y); EdgeSegment s = new EdgeSegment(); s.points.add(p); s.index = 0; s.parent = s.parentPixel = -1; e.segments.add(s); open.add(s); }
java
public static <T extends ImageBase<T>> void abs( T input , T output ) { if( input instanceof ImageGray) { if (GrayS8.class == input.getClass()) { PixelMath.abs((GrayS8) input, (GrayS8) output); } else if (GrayS16.class == input.getClass()) { PixelMath.abs((GrayS16) input, (GrayS16) output); } else i...
java