Detects corner features inside the input gray scale image.
972660
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--) {
			// find the corners
			detector.process(pyramid.get(level));

			// Add found corners to this level's list
			PyramidLevel featsLevel = featureLevels.get(level);

			FastQueue<ChessboardCorner> corners = detector.getCorners();
			featsLevel.corners.reset();
			for (int i = 0; i < corners.size; i++) {
				ChessboardCorner cf = corners.get(i);

				// convert the coordinate into input image coordinates
				double x = cf.x*scale;
				double y = cf.y*scale;
				// Compensate for how the pyramid was computed using an average down sample. It shifts
				// the coordinate system.
//				if( scale > 1 ) {
//					x += 0.5*scale;
//					y += 0.5*scale;
//				}

				ChessboardCorner cl = featsLevel.corners.grow();
				cl.first = true;
				cl.set(x,y,cf.orientation,cf.intensity);
			}
			scale /= 2.0;
		}

		// Create a combined set of features from all the levels. Only add each feature once by searching
		// for it in the next level down
		for (int levelIdx = 0; levelIdx < pyramid.size(); levelIdx++) {
			PyramidLevel level0 = featureLevels.get(levelIdx);

			// mark features in the next level as seen if they match ones in this level
			if( levelIdx+1< pyramid.size() ) {
				PyramidLevel level1 = featureLevels.get(levelIdx+1);
				markSeenAsFalse(level0.corners,level1.corners);
			}
		}

		for (int levelIdx = 0; levelIdx < pyramid.size(); levelIdx++) {
			PyramidLevel level = featureLevels.get(levelIdx);
			// only add corners if they were first seen in this level
			for (int i = 0; i < level.corners.size; i++) {
				ChessboardCorner c = level.corners.get(i);
				if( c.first )
					corners.grow().set(c);
			}
		}
	}
533539
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 minSides = getMinimumSides();
			for (int i = detections.size()-1; i >= 0; i-- ) {
				Polygon2D_F64 p = detections.get(i).polygon;
				adjustForBias.process(p, detector.isOutputClockwise());

				// When the polygon is adjusted for bias a point might need to be removed because it's
				// almost parallel. This could cause the shape to have too few corners and needs to be removed.
				if( p.size() < minSides)
					detections.remove(i);
			}
		}
		long time1 = System.nanoTime();

		double milli = (time1-time0)*1e-6;

		milliAdjustBias.update(milli);
//		System.out.printf(" contour %7.2f shapes %7.2f adjust_bias %7.2f\n",
//				detector.getMilliShapes(),detector.getMilliShapes(),milliAdjustBias);
	}
1225725
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 intensity in each level
		for( int i = 0; i < featureSize.length; i++ ) {
			GIntegralImageFeatureIntensity.hessian(integral,skip,featureSize[i],intensity[spaceIndex]);

			spaceIndex++;
			if( spaceIndex >= 3 )
				spaceIndex = 0;

			// find maximum in scale space
			if( i >= 2 ) {
				findLocalScaleSpaceMax(featureSize,i-1,skip);
			}
		}
	}
1337093
def add_corners(self, image_pair, show_results=False):
        
        side = "left"
        self.object_points.append(self.corner_coordinates)
        for image in image_pair:
            corners = self._get_corners(image)
            if show_results:
                self._show_corners(image, corners)
            self.image_points[side].append(corners.reshape(-1, 2))
            side = "right"
            self.image_count += 1
949435
private void checkDeclareAlg(GrayF32 image) {
		if( prevWidth != image.width || prevHeight != image.height ) {
			prevWidth = image.width;
			prevHeight = image.height;
			alg = new GeneralPurposeFFT_F32_2D(image.height,image.width);
		}
	}
1120821
def fit_from_image(self, data, voxelsize, seeds, unique_cls):
        
        fvs, clsselected = self.features_from_image(data, voxelsize, seeds, unique_cls)
        self.fit(fvs, clsselected)
937534
public void process( GrayF32 input ) {
//		System.out.println("ENTER CHESSBOARD CORNER "+input.width+" x "+input.height);
		borderImg.setImage(input);
		gradient.process(input,derivX,derivY);

		interpX.setImage(derivX);
		interpY.setImage(derivY);

		cornerIntensity.process(derivX,derivY,intensity);
		intensityInterp.setImage(intensity);

		// adjust intensity value so that its between 0 and levels for OTSU thresholding
		float featmax = ImageStatistics.max(intensity);
		PixelMath.multiply(intensity, GRAY_LEVELS /featmax,intensity);

//		int N = intensity.width*input.height;
//		for (int i = 0; i < N; i++) {
//			if( intensity.data[i] <= 2f ) {
//				intensity.data[i] = 0f;
//			}
//		}

		// convert into a binary image with high feature intensity regions being 1
		inputToBinary.process(intensity,binary);
		// find the small regions. Th se might be where corners are
		contourFinder.process(binary);

		corners.reset();
		List<ContourPacked> packed = contourFinder.getContours();
//		System.out.println("  * features.size = "+packed.size());
		for (int i = 0; i < packed.size(); i++) {
			contourFinder.loadContour(i,contour);

			ChessboardCorner c = corners.grow();

			UtilPoint2D_I32.mean(contour.toList(),c);
			// compensate for the bias caused by how pixels are counted.
			// Example: a 4x4 region is expected. Center should be at (2,2) but will instead be (1.5,1.5)
			c.x += 0.5;
			c.y += 0.5;

			computeFeatures(c.x,c.y,c);

//			System.out.println("radius = "+radius+" angle = "+c.angle);
//			System.out.println("intensity "+c.intensity);
			if( c.intensity < cornerIntensityThreshold ) {
				corners.removeTail();
			} else if( useMeanShift ) {
				meanShiftLocation(c);
				// TODO does it make sense to use mean shift first?
				computeFeatures(c.x,c.y,c);
			}
		}

//		System.out.println("Dropped "+dropped+" / "+packed.size());
	}
1008126
public void process( double c_x , double c_y , double sigma )
	{
		// convert to image coordinates
		int x = (int)(c_x + 0.5);
		int y = (int)(c_y + 0.5);

		// Estimate its orientation(s)
		computeHistogram(x, y, sigma );

		// compute the descriptor
		findHistogramPeaks();
	}
430886
private void computePixelFeatures() {
		for (int y = 0; y < derivX.height; y++) {
			int pixelIndex = y*derivX.width;
			int endIndex = pixelIndex+derivX.width;
			for (; pixelIndex < endIndex; pixelIndex++ ) {
				float dx = derivX.data[pixelIndex];
				float dy = derivY.data[pixelIndex];

				// angle from 0 to pi radians
				orientation.data[pixelIndex] = UtilAngle.atanSafe(dy,dx) + GrlConstants.F_PId2;
				// gradient magnitude
				magnitude.data[pixelIndex] = Math.sqrt(dx*dx + dy*dy);
			}
		}
	}
84322
def bounds(self):
        """"""
        corners = [self.image_corner(corner) for corner in self.corner_types()]
        return Polygon([[corner.x, corner.y] for corner in corners])
1236519
public static void horizontal(GrayF32 input, GrayF32 output, int radius) {
		InputSanityCheck.checkSameShape(input , output);

		Kernel1D_F32 kernel = FactoryKernel.table1D_F32(radius,false);
		ConvolveJustBorder_General_SB.horizontal(kernel,ImageBorderValue.wrap(input,0),output);
		if(BoofConcurrency.USE_CONCURRENT ) {
			ImplConvolveBox_MT.horizontal(input, output, radius);
		} else {
			ImplConvolveBox.horizontal(input, output, radius);
		}
	}
310653
private void process(int[] srcImage, int[] dstImage, int x, int y)
    {
        final int b = getSourcePixel(srcImage, x, y - 1);
        final int d = getSourcePixel(srcImage, x - 1, y);
        final int e = getSourcePixel(srcImage, x, y);
        final int f = getSourcePixel(srcImage, x + 1, y);
        final int h = getSourcePixel(srcImage, x, y + 1);
        int e0 = e;
        int e1 = e;
        int e2 = e;
        int e3 = e;
        if (b != h && d != f)
        {
            e0 = d == b ? d : e;
            e1 = b == f ? f : e;
            e2 = d == h ? d : e;
            e3 = h == f ? f : e;
        }

        setDestPixel(dstImage, x * SCALE, y * SCALE, e0);
        setDestPixel(dstImage, x * SCALE + 1, y * SCALE, e1);
        setDestPixel(dstImage, x * SCALE, y * SCALE + 1, e2);
        setDestPixel(dstImage, x * SCALE + 1, y * SCALE + 1, e3);
    }
960829
private void squaresToPositionList() {
		this.positionPatterns.reset();
		List<DetectPolygonFromContour.Info> infoList = squareDetector.getPolygonInfo();
		for (int i = 0; i < infoList.size(); i++) {
			DetectPolygonFromContour.Info info = infoList.get(i);

			// The test below has been commented out because the new external only contour
			// detector discards all information related to internal contours
			// squares with no internal contour cannot possibly be a finder pattern
//			if( !info.hasInternal() )
//				continue;

			// See if the appearance matches a finder pattern
			double grayThreshold = (info.edgeInside+info.edgeOutside)/2;
			if( !checkPositionPatternAppearance(info.polygon,(float)grayThreshold))
				continue;

			// refine the edge estimate
			squareDetector.refine(info);

			PositionPatternNode pp = this.positionPatterns.grow();
			pp.reset();
			pp.square = info.polygon;
			pp.grayThreshold = grayThreshold;

			graph.computeNodeInfo(pp);
		}
	}
30613
def _validate_image_orientation(image_orientation):
    '''
    
    '''
    row_cosine, column_cosine, slice_cosine = _extract_cosines(image_orientation)

    if not _almost_zero(np.dot(row_cosine, column_cosine), 1e-4):
        raise DicomImportException("Non-orthogonal direction cosines: {}, {}".format(row_cosine, column_cosine))
    elif not _almost_zero(np.dot(row_cosine, column_cosine), 1e-8):
        logger.warning("Direction cosines aren't quite orthogonal: {}, {}".format(row_cosine, column_cosine))

    if not _almost_one(np.linalg.norm(row_cosine), 1e-4):
        raise DicomImportException("The row direction cosine's magnitude is not 1: {}".format(row_cosine))
    elif not _almost_one(np.linalg.norm(row_cosine), 1e-8):
        logger.warning("The row direction cosine's magnitude is not quite 1: {}".format(row_cosine))

    if not _almost_one(np.linalg.norm(column_cosine), 1e-4):
        raise DicomImportException("The column direction cosine's magnitude is not 1: {}".format(column_cosine))
    elif not _almost_one(np.linalg.norm(column_cosine), 1e-8):
        logger.warning("The column direction cosine's magnitude is not quite 1: {}".format(column_cosine))
937143
protected Planar<GrayF32> preprocess(Planar<GrayF32> image) {
		super.preprocess(image);

		// image net is BGR color order
		imageBgr.bands[0] = imageRgb.bands[2];
		imageBgr.bands[1] = imageRgb.bands[1];
		imageBgr.bands[2] = imageRgb.bands[0];

		// image needs to be between 0 and 1
		GPixelMath.divide(imageBgr,255,imageBgr);

		// Normalize the image's statistics
		for (int band = 0; band < 3; band++) {
			DataManipulationOps.normalize(imageBgr.getBand(band),mean[band],stdev[band]);
		}

		return imageBgr;
	}
195467
def round_corner(radius, fill):
    """"""
    corner = Image.new('L', (radius, radius), 0)  # (0, 0, 0, 0))
    draw = ImageDraw.Draw(corner)
    draw.pieslice((0, 0, radius * 2, radius * 2), 180, 270, fill=fill)
    return corner
562007
public static void process(GrayI input, GrayI output, int radius , int[] storage ) {

		int w = 2*radius+1;
		if( storage == null ) {
			storage = new int[ w*w ];
		} else if( storage.length < w*w ) {
			throw new IllegalArgumentException("'storage' must be at least of length "+(w*w));
		}

		for( int y = 0; y < input.height; y++ ) {
			int minI = y - radius;
			int maxI = y + radius+1;

			// bound the y-axius inside the image
			if( minI < 0 ) minI = 0;
			if( maxI > input.height ) maxI = input.height;

			for( int x = 0; x < input.width; x++ ) {
				int minJ = x - radius;
				int maxJ = x + radius+1;

				// bound the x-axis to be inside the image
				if( minJ < 0 ) minJ = 0;
				if( maxJ > input.width ) maxJ = input.width;

				int index = 0;

				for( int i = minI; i < maxI; i++ ) {
					for( int j = minJ; j < maxJ; j++ ) {
						storage[index++] = input.get(j,i);
					}
				}
				
				// use quick select to avoid sorting the whole list
				int median = QuickSelect.select(storage, index / 2, index);
				output.set(x,y, median );
			}
		}
	}