当前位置: 首页>>代码示例>>Java>>正文


Java GThresholdImageOps.threshold方法代码示例

本文整理汇总了Java中boofcv.alg.filter.binary.GThresholdImageOps.threshold方法的典型用法代码示例。如果您正苦于以下问题:Java GThresholdImageOps.threshold方法的具体用法?Java GThresholdImageOps.threshold怎么用?Java GThresholdImageOps.threshold使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在boofcv.alg.filter.binary.GThresholdImageOps的用法示例。


在下文中一共展示了GThresholdImageOps.threshold方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: process

import boofcv.alg.filter.binary.GThresholdImageOps; //导入方法依赖的package包/类
/**
 * Processes the image and automatically detects calibration grid.  If successful then
 * true is returned and the found target is contained in the target detector.
 *
 * @param detector Target detection algorithm.
 * @param gray Gray scale image which is being thresholded
 * @return true if a threshold was successfully found and target detected.
 */
public boolean process( DetectSquareCalibrationPoints detector , ImageFloat32 gray ) {

	binary.reshape(gray.width,gray.height);

	double threshold = initialThreshold;
	if( threshold < 0 )
		threshold = UtilCalibrationGrid.selectThreshold(gray,histogram);

	GThresholdImageOps.threshold(gray,binary,threshold,true);

	// see if the target was detected
	if( detector.process(binary) ) {
		refinedThreshold = refineThreshold(detector.getInterestSquares(),gray);
		GThresholdImageOps.threshold(gray,binary,threshold,true);
		if( !detector.process(binary) ) {
			throw new RuntimeException("Crap new threshold doesn't work!");
		}
		return true;
	}

	return false;
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:31,代码来源:AutoThresholdCalibrationGrid.java

示例2: detect

import boofcv.alg.filter.binary.GThresholdImageOps; //导入方法依赖的package包/类
@Override
public List<LineSegment2D_F32> detect(T input) {

	derivX.reshape(input.width,input.height);
	derivY.reshape(input.width,input.height);
	edgeIntensity.reshape(input.width,input.height);
	detected.reshape(input.width,input.height);

	gradient.process(input,derivX,derivY);
	GGradientToEdgeFeatures.intensityAbs(derivX, derivY, edgeIntensity);
	GThresholdImageOps.threshold(edgeIntensity, detected, edgeThreshold, false);

	detectorGrid.process(derivX,derivY,detected);

	MatrixOfList<LineSegment2D_F32> grid = detectorGrid.getFoundLines();
	if( connect != null ) {
		connect.process(grid);
	}

	List<LineSegment2D_F32> found = grid.createSingleList();
	LineImageOps.mergeSimilar(found, (float) (Math.PI * 0.03), 5f);

	return found;
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:25,代码来源:DetectLineSegmentsGridRansac.java

示例3: performWork

import boofcv.alg.filter.binary.GThresholdImageOps; //导入方法依赖的package包/类
private synchronized void performWork() {
	if( filter == null )
		return;
	GThresholdImageOps.threshold(imageInput, imageBinary, selectThresh.getThreshold(), selectThresh.isDown());
	filter.process(imageBinary,imageOutput);

	SwingUtilities.invokeLater(new Runnable() {
		public void run() {
			if (work == null || work.getWidth() != imageInput.width || work.getHeight() != imageInput.height) {
				work = new BufferedImage(imageInput.width, imageInput.height, BufferedImage.TYPE_INT_BGR);
			}
			VisualizeBinaryData.renderBinary(selectedVisualize, work);
			gui.setBufferedImage(work);
			gui.setPreferredSize(new Dimension(imageInput.width, imageInput.height));
			processedImage = true;
			gui.repaint();
		}
	});
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:20,代码来源:DemoBinaryImageOpsApp.java

示例4: performWork

import boofcv.alg.filter.binary.GThresholdImageOps; //导入方法依赖的package包/类
private synchronized void performWork() {
	if( filter1 == null || filter2 == null )
		return;
	GThresholdImageOps.threshold(imageInput, imageBinary, selectThresh.getThreshold(), selectThresh.isDown());
	filter1.process(imageBinary,imageOutput1);
	filter2.process(imageOutput1,imageOutput2);
	List<Contour> found = BinaryImageOps.contour(imageOutput2, connectRule, imageLabeled);
	if( colors == null || colors.length <= found.size() )
		colors = BinaryImageOps.selectRandomColors(found.size(),rand);

	SwingUtilities.invokeLater(new Runnable() {
		public void run() {
			if (work == null || work.getWidth() != imageInput.width || work.getHeight() != imageInput.height) {
				work = new BufferedImage(imageInput.width, imageInput.height, BufferedImage.TYPE_INT_BGR);
			}
			renderVisualizeImage();
			gui.setBufferedImage(work);
			gui.setPreferredSize(new Dimension(imageInput.width, imageInput.height));
			processedImage = true;
			gui.repaint();
		}
	});
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:24,代码来源:DemoBinaryImageLabelOpsApp.java

示例5: detectChessBoard

import boofcv.alg.filter.binary.GThresholdImageOps; //导入方法依赖的package包/类
/**
 * Threshold the image and find squares
 */
private boolean detectChessBoard(T gray, double threshold , boolean first ) {

	actualBinaryThreshold = threshold;
	if( actualBinaryThreshold < 0 )
		actualBinaryThreshold = UtilCalibrationGrid.selectThreshold(gray,histogram);

	GThresholdImageOps.threshold(gray, binary, actualBinaryThreshold, true);

	// erode to make the squares separated
	BinaryImageOps.erode8(binary, eroded);

	if (findBound.process(eroded)) {
		if( userBinaryThreshold < 0 ) {
			// second pass to improve threshold
			return detectChessBoardSubImage(gray);
		} else {
			return true;
		}
	} else if( first && userBinaryThreshold < 0 ) {
		// if the target is small and the background dark, the threshold will be too low
		// if the target is small and the background white, it will still estimate a good threshold
		// so try a larger value before giving up
		threshold = (255+threshold)/2;
		return detectChessBoard(gray,threshold,false);
	}

	return false;
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:32,代码来源:DetectChessCalibrationPoints.java

示例6: detectChessBoardSubImage

import boofcv.alg.filter.binary.GThresholdImageOps; //导入方法依赖的package包/类
/**
 * Look for the target only inside a specific region.  The threshold can be more accurate selected this way
 */
private boolean detectChessBoardSubImage( T gray ) {

	// region the target is contained inside of
	ImageRectangle targetBound = findBound.getBoundRect();

	// expand the bound a bit
	int w = targetBound.getWidth();
	int h = targetBound.getHeight();

	ImageRectangle expanded = new ImageRectangle();
	int adj = (int)(w*0.12);
	expanded.x0 = targetBound.x0-adj;
	expanded.x1 = targetBound.x1+adj;
	adj = (int)(h*0.12);
	expanded.y0 = targetBound.y0-adj;
	expanded.y1 = targetBound.y1+adj;

	BoofMiscOps.boundRectangleInside(gray, expanded);

	// create sub-images for processing.  recompute threshold just around the area of interest and
	// only look for the target inside that
	T subGray = (T)gray.subimage(expanded.x0,expanded.y0,expanded.x1,expanded.y1);
	actualBinaryThreshold = UtilCalibrationGrid.selectThreshold(subGray,histogram);

	GImageMiscOps.fill(binary,0);
	ImageUInt8 subBinary = (ImageUInt8)binary.subimage(expanded.x0,expanded.y0,expanded.x1,expanded.y1);
	GThresholdImageOps.threshold(subGray, subBinary, actualBinaryThreshold, true);

	// The new threshold tends to require two erodes
	BinaryImageOps.erode8(binary, eroded);
	BinaryImageOps.erode4(eroded, binary);
	BinaryImageOps.dilate4(binary, eroded);

	if (findBound.process(eroded))
		return true;

	return false;
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:42,代码来源:DetectChessCalibrationPoints.java

示例7: detectTarget

import boofcv.alg.filter.binary.GThresholdImageOps; //导入方法依赖的package包/类
/**
 * Process the gray scale image.  Use a manually selected threshold or
 */
private void detectTarget() {

	if( calibGUI.isManual() ) {
		GThresholdImageOps.threshold(gray,binary,calibGUI.getThresholdLevel(),true);

		foundTarget = alg.process(binary);
	} else {
		foundTarget = auto.process(alg,gray);
		calibGUI.setThreshold((int)auto.getThreshold());
		binary.setTo(auto.getBinary());
	}

}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:17,代码来源:DetectCalibrationSquaresApp.java

示例8: doProcess

import boofcv.alg.filter.binary.GThresholdImageOps; //导入方法依赖的package包/类
private void doProcess() {
	if( input == null )
		return;

	final BufferedImage temp;

	if( activeAlg == 0 ) {
		if( previousBlur != barCanny.getBlurRadius() ) {
			previousBlur = barCanny.getBlurRadius();
			canny =  FactoryEdgeDetectors.canny(previousBlur,true, true, imageType, derivType);
		}

		double thresh = barCanny.getThreshold()/100.0;
		canny.process(workImage,(float)thresh*0.1f,(float)thresh,null);
		List<EdgeContour> contours = canny.getContours();

		temp = VisualizeBinaryData.renderContours(contours,null,workImage.width,workImage.height,null);
	} else {
		// create a binary image by thresholding
		GThresholdImageOps.threshold(workImage, binary, barBinary.getThreshold(), barBinary.isDown());

		contour.process(binary,labeled);
		temp = VisualizeBinaryData.renderContours(contour.getContours().toList(),null,0xFF1010,
				workImage.width,workImage.height,null);
	}

	SwingUtilities.invokeLater(new Runnable() {
		public void run() {
			panel.setBufferedImage(temp);
			panel.repaint();
		}});
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:33,代码来源:ShowEdgeContourApp.java

示例9: process

import boofcv.alg.filter.binary.GThresholdImageOps; //导入方法依赖的package包/类
public void process( final BufferedImage input ) {
	setInputImage(input);
	this.input.reshape(input.getWidth(),input.getHeight());
	ConvertBufferedImage.convertFromSingle(input, this.input, ImageUInt8.class);
	this.binary.reshape(input.getWidth(), input.getHeight());
	this.filtered.reshape(input.getWidth(),input.getHeight());
	this.output = new BufferedImage( input.getWidth(), input.getHeight(), BufferedImage.TYPE_INT_RGB);

	// the mean pixel value is often a reasonable threshold when creating a binary image
	double mean = ImageStatistics.mean(this.input);

	// create a binary image by thresholding
	GThresholdImageOps.threshold(this.input, binary, mean, true);

	// reduce noise with some filtering
	BinaryImageOps.erode8(binary, filtered);
	BinaryImageOps.dilate8(filtered, binary);

	// Find the contour around the shapes
	contours = BinaryImageOps.contour(binary,8,null);

	SwingUtilities.invokeLater(new Runnable() {
		public void run() {
			gui.setPreferredSize(new Dimension(input.getWidth(), input.getHeight()));
			processImage = true;
		}});
	doRefreshAll();
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:29,代码来源:ShapeFitContourApp.java

示例10: thresholdOtsu

import boofcv.alg.filter.binary.GThresholdImageOps; //导入方法依赖的package包/类
/**
 * @see GThresholdImageOps#computeOtsu
 */
public SimpleBinary thresholdOtsu(boolean down ) {
	double threshold = GThresholdImageOps.computeOtsu(image,0,255);
	return new SimpleBinary(GThresholdImageOps.threshold(image, null, threshold, down));
}
 
开发者ID:lessthanoptimal,项目名称:BoofProcessing,代码行数:8,代码来源:SimpleGray.java

示例11: thresholdEntropy

import boofcv.alg.filter.binary.GThresholdImageOps; //导入方法依赖的package包/类
/**
 * @see GThresholdImageOps#computeEntropy
 */
public SimpleBinary thresholdEntropy(boolean down ) {
	double threshold = GThresholdImageOps.computeEntropy(image,0,255);
	return new SimpleBinary(GThresholdImageOps.threshold(image, null, threshold, down));
}
 
开发者ID:lessthanoptimal,项目名称:BoofProcessing,代码行数:8,代码来源:SimpleGray.java

示例12: detectEdgePoints

import boofcv.alg.filter.binary.GThresholdImageOps; //导入方法依赖的package包/类
/**
	 * Detects edges along the black square.  If the square is partially inside a pixel the
	 * pixel's value will be between the dark and light value.   In a perfect sensor the border
	 * region would be at most two pixels thick, both values lighter than the pure black square.
	 * This border is captured using two threshold, one 1/2 between light and dark, and one much
	 * close to light.
	 *
	 * One case is not handled correctly given perfect observations.  If the line splits 1/2 way down
	 * two pixels then the edge will only be one pixel thick and not two.
	 */
	private void detectEdgePoints( ImageFloat32 image ) {
		// Added or subtracted one to handle pathological case where sigma is zero
		double lowThresh = low.getMean()+low.getSigma()*3+1;
		double highThresh = high.getMean()-high.getSigma()*3-1;

		// sanity check
		if( highThresh <= lowThresh ) {
//			BoofMiscOps.print(image);
//			for( int i = 0; i < histHighRes.histogram.length; i++ ) {
//				int c = histHighRes.histogram[i];
//				if( c != 0 ) {
//					System.out.println("["+i+"] = "+c);
//				}
//			}
//			return;
			throw new InvalidCalibrationTarget("Bad statistics");
		}

		// do a threshold in the middle first
		double middleThresh = (lowThresh*0.5+highThresh*0.5);

		// extract two regions at different threshold levels
		GThresholdImageOps.threshold(image, binaryMiddle,middleThresh,true);
		removeBinaryNoise(binaryMiddle);
		// binaryMiddle will be a subset of binaryHigh
		GThresholdImageOps.threshold(image, binaryHigh,highThresh,true);
		removeBinaryNoise(binaryHigh);

//		UtilImageIO.print(image);
//		UtilImageIO.print(binaryHigh);

		
		// find the region outside of 'binaryMiddle' in 'binaryHigh' and include
		// the edges in 'binaryMiddle'
		BinaryImageOps.logicXor(binaryMiddle, binaryHigh, binaryHigh);
		BinaryImageOps.edge4(binaryMiddle, binary);
		BinaryImageOps.logicOr(binaryHigh,binary,binary);

//		binary.print();
//		System.out.println("--------------------");

		// extract the points from the binary image and compute weights
		// weight is a linear function of distance from black square value
		points.reset();
		double middle = (high.getMean()+low.getMean())/2;
		for( int y = 0; y < height; y++ ) {
			for( int x = 0; x < width; x++ ) {
				if( binary.get(x,y) == 1 ) {
					PointInfo p = points.grow();
					p.set(x,y);
					double v = image.get(x,y);
					// weight pixels more that are close to the middle value since only an
					// edge point can have that value
					p.weight = 1.0-Math.abs(middle-v)/middle;
					p.weight = p.weight*p.weight;
				}
			}
		}
	}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:70,代码来源:RefineCornerSegmentFit.java

示例13: process

import boofcv.alg.filter.binary.GThresholdImageOps; //导入方法依赖的package包/类
@Override
public synchronized void process() {
	GThresholdImageOps.threshold(input, binary, 75, true);
	alg.process(binary,labeled);
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:6,代码来源:BenchmarkForOpenCV.java

示例14: process

import boofcv.alg.filter.binary.GThresholdImageOps; //导入方法依赖的package包/类
public void process( BufferedImage image ) {
		int regionSize = 40;

		I input = GeneralizedImageOps.createSingleBand(imageType, image.getWidth(), image.getHeight());
		D derivX = GeneralizedImageOps.createSingleBand(derivType, image.getWidth(), image.getHeight());
		D derivY = GeneralizedImageOps.createSingleBand(derivType, image.getWidth(), image.getHeight());
		ImageFloat32 edgeIntensity =  new ImageFloat32(input.width,input.height);
		ImageFloat32 suppressed =  new ImageFloat32(input.width,input.height);
		ImageFloat32 orientation =  new ImageFloat32(input.width,input.height);
		ImageSInt8 direction = new ImageSInt8(input.width,input.height);
		ImageUInt8 detected = new ImageUInt8(input.width,input.height);

		GridLineModelDistance distance = new GridLineModelDistance((float)(Math.PI*0.75));
		GridLineModelFitter fitter = new GridLineModelFitter((float)(Math.PI*0.75));

		ModelMatcher<LinePolar2D_F32, Edgel> matcher =
				new Ransac<LinePolar2D_F32,Edgel>(123123,fitter,distance,25,1);

		ImageGradient<I,D> gradient = FactoryDerivative.sobel(imageType, derivType);

		System.out.println("Image width "+input.width+" height "+input.height);

		ConvertBufferedImage.convertFromSingle(image, input, imageType);
		gradient.process(input, derivX, derivY);
		GGradientToEdgeFeatures.intensityAbs(derivX, derivY, edgeIntensity);

		// non-max suppression on the lines
//		GGradientToEdgeFeatures.direction(derivX,derivY,orientation);
//		GradientToEdgeFeatures.discretizeDirection4(orientation,direction);
//		GradientToEdgeFeatures.nonMaxSuppression4(edgeIntensity,direction,suppressed);

		GThresholdImageOps.threshold(edgeIntensity,detected,30,false);

		GridRansacLineDetector<ImageFloat32> alg = new ImplGridRansacLineDetector_F32(40,10,matcher);

		alg.process((ImageFloat32) derivX, (ImageFloat32) derivY, detected);

		MatrixOfList<LineSegment2D_F32> gridLine = alg.getFoundLines();

		ConnectLinesGrid connect = new ConnectLinesGrid(Math.PI*0.01,1,8);
//		connect.process(gridLine);
//		LineImageOps.pruneClutteredGrids(gridLine,3);
		List<LineSegment2D_F32> found = gridLine.createSingleList();
		System.out.println("size = "+found.size());
		LineImageOps.mergeSimilar(found,(float)(Math.PI*0.03),5f);
//		LineImageOps.pruneSmall(found,40);
		System.out.println("after size = "+found.size());

		ImageLinePanel gui = new ImageLinePanel();
		gui.setBackground(image);
		gui.setLineSegments(found);
		gui.setPreferredSize(new Dimension(image.getWidth(),image.getHeight()));

		BufferedImage renderedBinary = VisualizeBinaryData.renderBinary(detected, null);

		ShowImages.showWindow(renderedBinary,"Detected Edges");
		ShowImages.showWindow(gui,"Detected Lines");
	}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:59,代码来源:VisualizeLineRansac.java


注:本文中的boofcv.alg.filter.binary.GThresholdImageOps.threshold方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。