code
stringlengths
73
34.1k
label
stringclasses
1 value
public void init() { N = getParameterLength(); jacR = new DMatrixRMaj[N]; for (int i = 0; i < N; i++) { jacR[i] = new DMatrixRMaj(3,3); } jacobian = new DMatrixRMaj(N,9); paramInternal = new double[N]; numericalJac = createNumericalAlgorithm(function); }
java
public void checkOneObservationPerView() { for (int viewIdx = 0; viewIdx < views.length; viewIdx++) { SceneObservations.View v = views[viewIdx]; for (int obsIdx = 0; obsIdx < v.size(); obsIdx++) { int a = v.point.get(obsIdx); for (int i = obsIdx+1; i < v.size(); i++) { if( a == v.point.get(i)) { ...
java
public static void profile( Performer performer , int num ) { long deltaTime = measureTime(performer,num); System.out.printf("%30s time = %8d ms per frame = %8.3f\n", performer.getName(),deltaTime,(deltaTime/(double)num)); // System.out.println(performer.getClass().getSimpleName...
java
protected void initialize(T input , GrayS32 output ) { this.graph = output; final int N = input.width*input.height; regionSize.resize(N); threshold.resize(N); for( int i = 0; i < N; i++ ) { regionSize.data[i] = 1; threshold.data[i] = K; graph.data[i] = i; // assign a unique label to each pixel since...
java
protected void mergeSmallRegions() { for( int i = 0; i < edgesNotMatched.size(); i++ ) { Edge e = edgesNotMatched.get(i); int rootA = find(e.indexA); int rootB = find(e.indexB); // see if they are already part of the same segment if( rootA == rootB ) continue; int sizeA = regionSize.get(rootA...
java
protected int find( int child ) { int root = graph.data[child]; if( root == graph.data[root] ) return root; int inputChild = child; while( root != child ) { child = root; root = graph.data[child]; } graph.data[inputChild] = root; return root; }
java
protected void computeOutput() { outputRegionId.reset(); outputRegionSizes.reset(); for( int y = 0; y < graph.height; y++ ) { int indexGraph = graph.startIndex + y*graph.stride; for( int x = 0; x < graph.width; x++ , indexGraph++) { int parent = graph.data[indexGraph]; if( parent == indexGraph ) { ...
java
public void apply( DMatrixRMaj H , DMatrixRMaj output ) { output.reshape(3,H.numCols); int stride = H.numCols; for (int col = 0; col < H.numCols; col++) { // This column in H double h1 = H.data[col], h2 = H.data[col+stride], h3 = H.data[col+2*stride]; output.data[col] = h1/stdX - meanX*h3/stdX; outpu...
java
public void apply(DMatrix3x3 C, DMatrix3x3 output) { DMatrix3x3 Hinv = matrixInv3(work); PerspectiveOps.multTranA(Hinv,C,Hinv,output); }
java
private static WlCoef_I32 generateInv_I32() { WlCoef_I32 ret = new WlCoef_I32(); ret.scaling = new int[]{1,1}; ret.wavelet = new int[]{ret.scaling[0],-ret.scaling[0]}; ret.denominatorScaling = 2; ret.denominatorWavelet = 2; return ret; }
java
public void updateTracks( I input , PyramidDiscrete<I> pyramid , D[] derivX, D[] derivY ) { // forget recently dropped or spawned tracks tracksSpawned.clear(); // save references this.input = input; trackerKlt.setInputs(pyramid, derivX, derivY); trackUsingKlt(tracksPureKlt); ...
java
private void trackUsingKlt(List<CombinedTrack<TD>> tracks) { for( int i = 0; i < tracks.size(); ) { CombinedTrack<TD> track = tracks.get(i); if( !trackerKlt.performTracking(track.track) ) { // handle the dropped track tracks.remove(i); tracksDormant.add(track); } else { track.set(track.trac...
java
public void spawnTracksFromDetected() { // mark detected features with no matches as available FastQueue<AssociatedIndex> matches = associate.getMatches(); int N = detector.getNumberOfFeatures(); for( int i = 0; i < N; i++ ) associated[i] = false; for( AssociatedIndex i : matches.toList() ) { associat...
java
private void associateToDetected( List<CombinedTrack<TD>> known ) { // initialize data structures detectedDesc.reset(); knownDesc.reset(); // create a list of detected feature descriptions int N = detector.getNumberOfFeatures(); for( int i = 0; i < N; i++ ) { detectedDesc.add(detector.getDescription(i))...
java
public void associateAllToDetected() { // initialize data structures List<CombinedTrack<TD>> all = new ArrayList<>(); all.addAll(tracksReactivated); all.addAll(tracksDormant); all.addAll(tracksPureKlt); int numTainted = tracksReactivated.size() + tracksDormant.size(); tracksReactivated.clear(); tracks...
java
public boolean dropTrack( CombinedTrack<TD> track ) { if( !tracksPureKlt.remove(track) ) if( !tracksReactivated.remove(track) ) if( !tracksDormant.remove(track) ) return false; tracksUnused.add(track); return true; }
java
public void dropAllTracks() { tracksUnused.addAll(tracksDormant); tracksUnused.addAll(tracksPureKlt); tracksUnused.addAll(tracksReactivated); tracksSpawned.clear(); tracksPureKlt.clear(); tracksReactivated.clear(); tracksSpawned.clear(); tracksDormant.clear(); }
java
private void processImage() { final List<Point2D_F64> leftPts = new ArrayList<>(); final List<Point2D_F64> rightPts = new ArrayList<>(); final List<TupleDesc> leftDesc = new ArrayList<>(); final List<TupleDesc> rightDesc = new ArrayList<>(); final ProgressMonitor progressMonitor = new ProgressMonitor(this, ...
java
private void extractImageFeatures(final ProgressMonitor progressMonitor, final int progress, T image, List<TupleDesc> descs, List<Point2D_F64> locs) { SwingUtilities.invokeLater(new Runnable() { public void run() { progressMonitor.setNote("Detecting"); } }); detector.detect(image);...
java
protected void resizeForLayer( int width , int height ) { deriv1X.reshape(width,height); deriv1Y.reshape(width,height); deriv2X.reshape(width,height); deriv2Y.reshape(width,height); deriv2XX.reshape(width,height); deriv2YY.reshape(width,height); deriv2XY.reshape(width,height); warpImage2.reshape(width,...
java
private void computePsiSmooth(GrayF32 ux , GrayF32 uy , GrayF32 vx , GrayF32 vy , GrayF32 psiSmooth ) { int N = derivFlowUX.width * derivFlowUX.height; for( int i = 0; i < N; i++ ) { float vux = ux.data[i]; float vuy = uy.data[i]; float vvx = vx.data[i]; float vvy = vy.data[i]; float mu =...
java
protected void computePsiDataPsiGradient(GrayF32 image1, GrayF32 image2, GrayF32 deriv1x, GrayF32 deriv1y, GrayF32 deriv2x, GrayF32 deriv2y, GrayF32 deriv2xx, GrayF32 deriv2yy, GrayF32 deriv2xy, GrayF32 du, GrayF32 dv, GrayF32 psiData, GrayF32 psiGradient ) { ...
java
private void computeDivUVD(GrayF32 u , GrayF32 v , GrayF32 psi , GrayF32 divU , GrayF32 divV , GrayF32 divD ) { final int stride = psi.stride; // compute the inside pixel for (int y = 1; y < psi.height-1; y++) { // index of the current pixel int index = y*stride + 1; for (int x = 1; x < psi...
java
public void reset() { unused.addAll(templateNegative); unused.addAll(templatePositive); templateNegative.clear(); templatePositive.clear(); }
java
public void addDescriptor( boolean positive , ImageRectangle rect ) { addDescriptor(positive, rect.x0, rect.y0, rect.x1, rect.y1); }
java
private void addDescriptor(boolean positive, NccFeature f) { // avoid adding the same descriptor twice or adding contradicting results if( positive) if( distance(f,templatePositive) < 0.05 ) { return; } if( !positive) { if( distance(f,templateNegative) < 0.05 ) { return; } // a positive pos...
java
public void computeNccDescriptor( NccFeature f , float x0 , float y0 , float x1 , float y1 ) { double mean = 0; float widthStep = (x1-x0)/15.0f; float heightStep = (y1-y0)/15.0f; // compute the mean value int index = 0; for( int y = 0; y < 15; y++ ) { float sampleY = y0 + y*heightStep; for( int x = 0...
java
public NccFeature createDescriptor() { NccFeature f; if( unused.isEmpty() ) f = new NccFeature(15*15); else f = unused.pop(); return f; }
java
public double computeConfidence( int x0 , int y0 , int x1 , int y1 ) { computeNccDescriptor(observed,x0,y0,x1,y1); // distance from each set of templates if( templateNegative.size() > 0 && templatePositive.size() > 0 ) { double distancePositive = distance(observed,templatePositive); double distanceNegativ...
java
public double computeConfidence( ImageRectangle r ) { return computeConfidence(r.x0,r.y0,r.x1,r.y1); }
java
public double distance( NccFeature observed , List<NccFeature> candidates ) { double maximum = -Double.MAX_VALUE; // The feature which has the best fit will maximize the score for( NccFeature f : candidates ) { double score = DescriptorDistance.ncc(observed, f); if( score > maximum ) maximum = score; ...
java
public void process(GrayF32 input ) { constructPyramid(input); corners.reset(); // top to bottom. This way the intensity image is at the input image's scale. Which is useful // for visualiztion purposes double scale = Math.pow(2.0,pyramid.size()-1); for (int level = pyramid.size()-1; level >= 0; level--) ...
java
void markSeenAsFalse(FastQueue<ChessboardCorner> corners0 , FastQueue<ChessboardCorner> corners1 ) { nn.setPoints(corners1.toList(),false); // radius of the blob in the intensity image is 2*kernelRadius int radius = detector.shiRadius *2+1; for (int i = 0; i < corners0.size; i++) { ChessboardCorner c0 = corn...
java
@Override public void processImage(int sourceID, long frameID, final BufferedImage buffered, ImageBase input) { System.out.flush(); synchronized (bufferedImageLock) { original = ConvertBufferedImage.checkCopy(buffered, original); work = ConvertBufferedImage.checkDeclare(buffered, work); } if( saveReque...
java
public boolean computeHomography( CalibrationObservation observedPoints ) { if( observedPoints.size() < 4) throw new IllegalArgumentException("At least 4 points needed in each set of observations. " + " Filter these first please"); List<AssociatedPair> pairs = new ArrayList<>(); for( int i = 0; i < obse...
java
public synchronized void recycle( float[] array ) { if( array.length != length ) { throw new IllegalArgumentException("Unexpected array length. Expected "+length+" found "+array.length); } storage.add(array); }
java
private void visualizeResults( SceneStructureMetric structure, List<BufferedImage> colorImages ) { List<Point3D_F64> cloudXyz = new ArrayList<>(); GrowQueue_I32 cloudRgb = new GrowQueue_I32(); Point3D_F64 world = new Point3D_F64(); Point3D_F64 camera = new Point3D_F64(); Point2D_F64 pixel = new Po...
java
public static void decodeFormatMessage(int message , QrCode qr ) { int error = message >> 3; qr.error = QrCode.ErrorLevel.lookup(error); qr.mask = QrCodeMaskPattern.lookupMask(message&0x07); }
java
public static int correctDCH( int N , int messageNoMask , int generator , int totalBits, int dataBits) { int bestHamming = 255; int bestMessage = -1; int errorBits = totalBits-dataBits; // exhaustively check all possibilities for (int i = 0; i < N; i++) { int test = i << errorBits; test = test ^ bitPo...
java
private static void displayResults(BufferedImage orig, Planar<GrayF32> distortedImg, ImageDistort allInside, ImageDistort fullView ) { // render the results Planar<GrayF32> undistortedImg = new Planar<>(GrayF32.class, distortedImg.getWidth(),distortedImg.getHeight(),distortedImg.getNumBa...
java
public boolean process( double sampleRadius , Quadrilateral_F64 input ) { work.set(input); samples.reset(); estimator.process(work,false); estimator.getWorldToCamera().invert(referenceCameraToWorld); samples.reset(); createSamples(sampleRadius,work.a,input.a); createSamples(sampleRadius,work.b,input.b)...
java
private void createSamples( double sampleRadius , Point2D_F64 workPoint , Point2D_F64 originalPoint ) { workPoint.x = originalPoint.x + sampleRadius; if( estimator.process(work,false) ) { samples.grow().set( estimator.getWorldToCamera() ); } workPoint.x = originalPoint.x - sampleRadius; if( estimator.proc...
java
public void initialLearning( Rectangle2D_F64 targetRegion , FastQueue<ImageRectangle> cascadeRegions ) { storageMetric.reset(); fernNegative.clear(); // learn the initial descriptor TldHelperFunctions.convertRegion(targetRegion, targetRegion_I32); // select the variance the first time using user s...
java
public void updateLearning( Rectangle2D_F64 targetRegion ) { storageMetric.reset(); // learn the initial descriptor TldHelperFunctions.convertRegion(targetRegion, targetRegion_I32); template.addDescriptor(true, targetRegion_I32); fern.learnFernNoise(true, targetRegion_I32); // mark only a few of the far...
java
protected void learnAmbiguousNegative(Rectangle2D_F64 targetRegion) { TldHelperFunctions.convertRegion(targetRegion, targetRegion_I32); if( detection.isSuccess() ) { TldRegion best = detection.getBest(); // see if it found the correct solution double overlap = helper.computeOverlap(best.rect,targetRegio...
java
public static <T extends ImageGray<T>> InputToBinary<T> localOtsu(ConfigLength regionWidth, double scale, boolean down, boolean otsu2, double tuning, Class<T> inputType) { if( BOverrideFactoryThresholdBinary.localOtsu != null ) return BOverrideFactoryThresholdBinary.localOtsu.handle(otsu2,regionWidth, tuning, sca...
java
public static <T extends ImageGray<T>> InputToBinary<T> blockMean(ConfigLength regionWidth, double scale , boolean down, boolean thresholdFromLocalBlocks, Class<T> inputType) { if( BOverrideFactoryThresholdBinary.blockMean != null ) return BOverrideFactoryThresholdBinary.blockMean.handle(regionWidth, sc...
java
public static <T extends ImageGray<T>> InputToBinary<T> blockOtsu(ConfigLength regionWidth, double scale, boolean down, boolean thresholdFromLocalBlocks, boolean otsu2, double tuning,Class<T> inputType) { if( BOverrideFactoryThresholdBinary.blockOtsu != null ) return BOverrideFactoryThresholdBinary.bloc...
java
public static <T extends ImageGray<T>> InputToBinary<T> threshold( ConfigThreshold config, Class<T> inputType) { switch( config.type ) { case FIXED: return globalFixed(config.fixedThreshold, config.down, inputType); case GLOBAL_OTSU: return globalOtsu(config.minPixelValue, config.maxPixelValue, confi...
java
public void constraintSouth(JComponent target, JComponent top, JComponent bottom, int padV ) { if( bottom == null ) { layout.putConstraint(SpringLayout.SOUTH, target, -padV, SpringLayout.SOUTH, this); } else { Spring a = Spring.sum(Spring.constant(-padV),layout.getConstraint(Spri...
java
public void setLensDistoriton(LensDistortionNarrowFOV distortion ) { pixelToNorm = distortion.undistort_F64(true,false); normToPixel = distortion.distort_F64(false, true); }
java
public void setFiducial( double x0 , double y0 , double x1 , double y1 , double x2 , double y2 , double x3 , double y3 ) { points.get(0).location.set(x0,y0,0); points.get(1).location.set(x1,y1,0); points.get(2).location.set(x2,y2,0); points.get(3).location.set(x3,y3,0); }
java
public void pixelToMarker( double pixelX , double pixelY , Point2D_F64 marker ) { // find pointing vector in camera reference frame pixelToNorm.compute(pixelX,pixelY,marker); cameraP3.set(marker.x,marker.y,1); // rotate into marker reference frame GeometryMath_F64.multTran(outputFiducialToCamera.R,cameraP3,...
java
protected boolean estimate( Quadrilateral_F64 cornersPixels , Quadrilateral_F64 cornersNorm , Se3_F64 foundFiducialToCamera ) { // put it into a list to simplify algorithms listObs.clear(); listObs.add( cornersPixels.a ); listObs.add( cornersPixels.b ); listObs.add( cornersPixels.c ); listOb...
java
protected void estimateP3P(int excluded) { // the point used to check the solutions is the last one inputP3P.clear(); for( int i = 0; i < 4; i++ ) { if( i != excluded ) { inputP3P.add( points.get(i) ); } } // initial estimate for the pose solutions.reset(); if( !p3p.process(inputP3P,solutions)...
java
protected void enlarge( Quadrilateral_F64 corners, double scale ) { UtilPolygons2D_F64.center(corners, center); extend(center,corners.a,scale); extend(center,corners.b,scale); extend(center,corners.c,scale); extend(center,corners.d,scale); }
java
protected double computeErrors(Se3_F64 fiducialToCamera ) { if( fiducialToCamera.T.z < 0 ) { // the low level algorithm should already filter this code, but just incase return Double.MAX_VALUE; } double maxError = 0; for( int i = 0; i < 4; i++ ) { maxError = Math.max(maxError,computePixelError(fiduci...
java
@Override public void encode(DMatrixRMaj F, double[] param) { // see if which columns are to be used selectColumns(F); // set the largest element in the first two columns and normalize // using that value double v[] = new double[]{F.get(0,col0),F.get(1,col0),F.get(2,col0), F.get(0,col1),F.get(1,col1),...
java
private double selectDivisor( double v[] , double param[] ) { double maxValue = 0; int maxIndex = 0; for( int i = 0; i < v.length; i++ ) { if( Math.abs(v[i]) > maxValue ) { maxValue = Math.abs(v[i]); maxIndex = i; } } double divisor = v[maxIndex]; int index = 0; for( int i = 0; i < v.leng...
java
protected void createEdge( String src , String dst , FastQueue<AssociatedPair> pairs , FastQueue<AssociatedIndex> matches ) { // Fitting Essential/Fundamental works when the scene is not planar and not pure rotation int countF = 0; if( ransac3D.process(pairs.toList()) ) { countF = ransac3D.getMatchSe...
java
private void saveInlierMatches(ModelMatcher<?, ?> ransac, FastQueue<AssociatedIndex> matches, PairwiseImageGraph2.Motion edge) { int N = ransac.getMatchSet().size(); edge.inliers.reset(); for (int i = 0; i < N; i++) { int idx = ransac.getInputIndex(i); edge.inliers.grow().set(matches.get(idx)); ...
java
protected void recycleData() { for (int i = 0; i < nodes.size(); i++) { SquareNode n = nodes.get(i); for (int j = 0; j < n.edges.length; j++) { if( n.edges[j] != null ) { graph.detachEdge(n.edges[j]); } } } for (int i = 0; i < nodes.size(); i++) { SquareNode n = nodes.get(i); for (int ...
java
protected void findClusters() { for (int i = 0; i < nodes.size(); i++) { SquareNode n = nodes.get(i); if( n.graph < 0 ) { n.graph = clusters.size(); List<SquareNode> graph = clusters.grow(); graph.add(n); addToCluster(n, graph); } } }
java
void addToCluster(SquareNode seed, List<SquareNode> graph) { open.clear(); open.add(seed); while( !open.isEmpty() ) { SquareNode n = open.remove( open.size() - 1 ); for (int i = 0; i < n.square.size(); i++) { SquareEdge edge = n.edges[i]; if( edge == null ) continue; SquareNode other; ...
java
public static void printClickedColor( final BufferedImage image ) { ImagePanel gui = new ImagePanel(image); gui.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { float[] color = new float[3]; int rgb = image.getRGB(e.getX(),e.getY()); ColorHsv.rgbToHsv((rgb >...
java
public static void showSelectedColor( String name , BufferedImage image , float hue , float saturation ) { Planar<GrayF32> input = ConvertBufferedImage.convertFromPlanar(image,null,true,GrayF32.class); Planar<GrayF32> hsv = input.createSameShape(); // Convert into HSV ColorHsv.rgbToHsv(input,hsv); // Euclid...
java
public static ImageDimension transformDimension( ImageBase orig , int level ) { return transformDimension(orig.width,orig.height,level); }
java
public static int borderForwardLower( WlCoef desc ) { int ret = -Math.min(desc.offsetScaling,desc.offsetWavelet); return ret + (ret % 2); }
java
public static int borderInverseLower( WlBorderCoef<?> desc, BorderIndex1D border ) { WlCoef inner = desc.getInnerCoefficients(); int borderSize = borderForwardLower(inner); WlCoef ll = borderSize > 0 ? inner : null; WlCoef lu = ll; WlCoef uu = inner; int indexLU = 0; if( desc.getLowerLength() > 0 ) { ...
java
public static int round( int top , int div2 , int divisor ) { if( top > 0 ) return (top + div2)/divisor; else return (top - div2)/divisor; }
java
public static void adjustForDisplay(ImageGray transform , int numLevels , double valueRange ) { if( transform instanceof GrayF32) adjustForDisplay((GrayF32)transform,numLevels,(float)valueRange); else adjustForDisplay((GrayI)transform,numLevels,(int)valueRange); }
java
public static void equalizeLocalNaive( GrayU8 input , int radius , GrayU8 output , IWorkArrays workArrays ) { int width = 2*radius+1; int maxValue = workArrays.length()-1; //CONCURRENT_BELOW BoofConcurrency.loopBlocks(0,input.height,(idx0,idx1)->{ int idx0 = 0, idx1 = input.height; int[] histog...
java
public static void equalizeLocalInner( GrayU8 input , int radius , GrayU8 output , IWorkArrays workArrays ) { int width = 2*radius+1; int area = width*width; int maxValue = workArrays.length()-1; //CONCURRENT_BELOW BoofConcurrency.loopBlocks(radius,input.height-radius,(y0,y1)->{ int y0 = radius, ...
java
public static void localHistogram( GrayU16 input , int x0 , int y0 , int x1, int y1 , int histogram[] ) { for( int i = 0; i < histogram.length; i++ ) histogram[i] = 0; for( int i = y0; i < y1; i++ ) { int index = input.startIndex + i*input.stride + x0; int end = index + x1-x0; for( ; index < end; index...
java
public synchronized void setBufferedImage(BufferedImage image) { // assume the image was initially set before the GUI was invoked if( checkEventDispatch && this.img != null ) { if( !SwingUtilities.isEventDispatchThread() ) throw new RuntimeException("Changed image when not in GUI thread?"); } this.img =...
java
public void initialize( T image , RectangleLength2D_I32 initial ) { if( !image.isInBounds(initial.x0,initial.y0) ) throw new IllegalArgumentException("Initial rectangle is out of bounds!"); if( !image.isInBounds(initial.x0+initial.width,initial.y0+initial.height) ) throw new IllegalArgumentException("Initial ...
java
public boolean process( T image ) { if( failed ) return false; targetModel.setImage(image); // mark the region where the pdf has been modified as dirty dirty.set(location.x0, location.y0, location.x0 + location.width, location.y0 + location.height); // compute the pdf inside the initial rectangle upda...
java
protected void updatePdfImage( int x0 , int y0 , int x1 , int y1 ) { for( int y = y0; y < y1; y++ ) { int indexOut = pdf.startIndex + pdf.stride*y + x0; for( int x = x0; x < x1; x++ , indexOut++ ) { if( pdf.data[indexOut] < 0 ) pdf.data[indexOut] = targetModel.compute(x, y); } } // update th...
java
@Override public void process( T image ) { // initialize data structures this.image = image; this.stopRequested = false; modeLocation.reset(); modeColor.reset(); modeMemberCount.reset(); interpolate.setImage(image); pixelToMode.reshape(image.width, image.height); quickMode.reshape(image.width, ima...
java
public void set( Point2D3D src ) { observation.set(src.observation); location.set(src.location); }
java
public void clearLensDistortion() { detector.clearLensDistortion(); if( refineGray != null ) refineGray.clearLensDistortion(); edgeIntensity.setTransform(null); }
java
public void process(T gray , GrayU8 binary ) { detector.process(gray,binary); if( refineGray != null ) refineGray.setImage(gray); edgeIntensity.setImage(gray); long time0 = System.nanoTime(); FastQueue<DetectPolygonFromContour.Info> detections = detector.getFound(); if( adjustForBias != null ) { int...
java
public boolean refine( DetectPolygonFromContour.Info info ) { double before,after; if( edgeIntensity.computeEdge(info.polygon,!detector.isOutputClockwise()) ) { before = edgeIntensity.getAverageOutside() - edgeIntensity.getAverageInside(); } else { return false; } boolean success = false; if( refine...
java
public void refineAll() { List<DetectPolygonFromContour.Info> detections = detector.getFound().toList(); for (int i = 0; i < detections.size(); i++) { refine(detections.get(i)); } }
java
public static <T extends ImageGray<T>> T checkReshape(T target , ImageGray testImage , Class<T> targetType ) { if( target == null ) { return GeneralizedImageOps.createSingleBand(targetType, testImage.width, testImage.height); } else if( target.width != testImage.width || target.height != testImage.height ) { ...
java
protected void findLocalScaleSpaceMax(PyramidFloat<T> ss, int layerID) { int index0 = spaceIndex; int index1 = (spaceIndex + 1) % 3; int index2 = (spaceIndex + 2) % 3; List<Point2D_I16> candidates = maximums[index1]; ImageBorder_F32 inten0 = (ImageBorder_F32) FactoryImageBorderAlgs.value(intensities[index0],...
java
int getCornerIndex( SquareNode node , double x , double y ) { for (int i = 0; i < node.square.size(); i++) { Point2D_F64 c = node.square.get(i); if( c.x == x && c.y == y ) return i; } throw new RuntimeException("BUG!"); }
java
boolean candidateIsMuchCloser( SquareNode node0 , SquareNode node1 , double distance2 ) { double length = Math.max(node0.largestSide,node1.largestSide)*tooFarFraction; length *= length; if( distance2 > length) return false; return distance2 <= length; }
java
private void handleContextMenu(JTree tree, int x, int y) { TreePath path = tree.getPathForLocation(x, y); tree.setSelectionPath(path); DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); if (node == null) return; if (!node.isLeaf()) { tree.setSelectionPath(null);...
java
private void openInGitHub( AppInfo info ) { if (Desktop.isDesktopSupported()) { try { URI uri = new URI(UtilIO.getGithubURL(info.app.getPackage().getName(), info.app.getSimpleName())); if (!uri.getPath().isEmpty()) Desktop.getDesktop().browse(uri); else System.err.println("Bad URL received")...
java
public void killAllProcesses( long blockTimeMS ) { // remove already dead processes from the GUI SwingUtilities.invokeLater(new Runnable() { @Override public void run() { DefaultListModel model = (DefaultListModel)processList.getModel(); for (int i = model.size()-1; i >= 0; i--) { ActiveProcess p...
java
@Override public void intervalAdded(ListDataEvent e) { //retrieve the most recently added process and display it DefaultListModel listModel = (DefaultListModel) e.getSource(); ActiveProcess process = (ActiveProcess) listModel.get(listModel.getSize() - 1); addProcessTab(process, outputPanel); }
java
protected void setUpEdges(GrayS32 input , GrayS32 output ) { if( connectRule == ConnectRule.EIGHT ) { setUpEdges8(input,edgesIn); setUpEdges8(output,edgesOut); edges[0].set( 1, 0); edges[1].set( 1, 1); edges[2].set( 0, 1); edges[3].set(-1, 0); } else { setUpEdges4(input,edgesIn); setUpEdge...
java
public void process(GrayS32 input , GrayS32 output , GrowQueue_I32 regionMemberCount ) { // initialize data structures this.regionMemberCount = regionMemberCount; regionMemberCount.reset(); setUpEdges(input,output); ImageMiscOps.fill(output,-1); // this is a bit of a hack here. Normally you call the pare...
java
protected void connectInner(GrayS32 input, GrayS32 output) { int startX = connectRule == ConnectRule.EIGHT ? 1 : 0; for( int y = 0; y < input.height-1; y++ ) { int indexIn = input.startIndex + y*input.stride + startX; int indexOut = output.startIndex + y*output.stride + startX; for( int x = startX; x < ...
java
protected void connectLeftRight(GrayS32 input, GrayS32 output) { for( int y = 0; y < input.height; y++ ) { int x = input.width-1; int inputLabel = input.unsafe_get(x, y); int outputLabel = output.unsafe_get(x, y); if( outputLabel == -1 ) { // see if it needs to create a new output segment outputLabe...
java
protected void connectBottom(GrayS32 input, GrayS32 output) { for( int x = 0; x < input.width-1; x++ ) { int y = input.height-1; int inputLabel = input.unsafe_get(x,y); int outputLabel = output.unsafe_get(x,y); if( outputLabel == -1 ) { // see if it needs to create a new output segment outputLabel =...
java
public void setImage(I image, D derivX, D derivY) { InputSanityCheck.checkSameShape(image, derivX, derivY); this.image = image; this.interpInput.setImage(image); this.derivX = derivX; this.derivY = derivY; }
java
@SuppressWarnings({"SuspiciousNameCombination"}) public boolean setDescription(KltFeature feature) { setAllowedBounds(feature); if (!isFullyInside(feature.x, feature.y)) { if( isFullyOutside(feature.x,feature.y)) return false; else return internalSetDescriptionBorder(feature); } return internal...
java
protected boolean internalSetDescriptionBorder(KltFeature feature) { computeSubImageBounds(feature, feature.x, feature.y); ImageMiscOps.fill(feature.desc, Float.NaN); feature.desc.subimage(dstX0, dstY0, dstX1, dstY1, subimage); interpInput.setImage(image); interpInput.region(srcX0, srcY0, subimage); feat...
java