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


Java Plot.drawLine方法代码示例

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


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

示例1: showPairCorrelation

import ij.gui.Plot; //导入方法依赖的package包/类
private PlotWindow showPairCorrelation(PC pc)
{
	double avDensity = (double) pc.n / pc.area;
	String title = "Pair Correlation";
	Plot plot2 = new Plot(TITLE + " " + title, "r (px)", "g(r)", pc.r, pc.pcf);
	plot2.setColor(Color.red);
	plot2.drawLine(pc.r[0], 1, pc.r[pc.r.length - 1], 1);
	plot2.addLabel(0, 0, "Av.Density = " + IJ.d2s(avDensity, -3) + " px^-2");
	plot2.setColor(Color.blue);
	return Utils.display(TITLE + " " + title, plot2);
}
 
开发者ID:aherbert,项目名称:GDSC,代码行数:12,代码来源:SpotDensity.java

示例2: main

import ij.gui.Plot; //导入方法依赖的package包/类
public static void main(String[] args) {
	
	//
	RANSAC ransac = new RANSAC();
	
	//
	// The point cloud is defined
	//
	
	SimpleMatrix pts = new SimpleMatrix(7,2);
	pts.setRowValue(0, new SimpleVector(0,0));
	pts.setRowValue(1, new SimpleVector(1,1));
	pts.setRowValue(2, new SimpleVector(2,2));
	pts.setRowValue(3, new SimpleVector(3,3));
	pts.setRowValue(4, new SimpleVector(3.2,1.9));
	pts.setRowValue(5, new SimpleVector(4,4));
	pts.setRowValue(6, new SimpleVector(10,1.8));


	//
	// Regression Line 
	//
	
	// Create a scatter plot of the point cloud and fit a regression line
	Plot scatterPlot = new Plot("Regression Line", "X", "Y", Plot.DEFAULT_FLAGS);
	scatterPlot.setLimits(0, 11, 0, 5);
	scatterPlot.addPoints(pts.getCol(0).copyAsDoubleArray(), pts.getCol(1).copyAsDoubleArray(), Plot.BOX);
	scatterPlot.show();
	
	// Calculate the regression line through the given point cloud
	SimpleVector regressionLine = ransac.fitline(pts);
	
	// Add the regression line
	double y11 = regressionLine.getElement(0) * 11 + regressionLine.getElement(1);
	double y0 = regressionLine.getElement(0) * 0 + regressionLine.getElement(1);
	scatterPlot.drawLine(0, y0, 11, y11);
	
	
	//
	// RANSAC 
	//
	
	// Parameters for RANSAC
	double p_opt = 0.9999; 		// probability how likely it is to pick the right mn points
	double p_out = 0.2;			// probability of an outlier
	int min_number = 2;			// minimum number of datapoints required to build the model

	// Create a scatter plot of the point cloud and fit a RANSAC line
	Plot ransac_plot = new Plot("Ransac Line", "X", "Y", Plot.DEFAULT_FLAGS);
	ransac_plot.setLimits(0, 11, 0, 5);
	ransac_plot.addPoints(pts.getCol(0).copyAsDoubleArray(), pts.getCol(1).copyAsDoubleArray(), Plot.BOX);
	
	
	// Compute a line using the RANSAC algorithm and plot it
	SimpleVector ransacLine = ransac.commonRansac(pts, min_number, p_opt, p_out);
	double y1 = ransacLine.getElement(0) * 0 + ransacLine.getElement(1);
	double y2 = ransacLine.getElement(0) * 11 + ransacLine.getElement(1);
	ransac_plot.drawLine(0, y1, 11, y2);
	ransac_plot.show();
		
}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:62,代码来源:RANSAC.java

示例3: createPlot

import ij.gui.Plot; //导入方法依赖的package包/类
private void createPlot()
{
	double[] xValues = createHistogramAxis(histogramX);
	double[] yValues = createHistogramValues(normalisedHistogram);

	// Set the upper limit for the plot
	double maxHistogram = 0;
	for (double d : normalisedHistogram)
		if (maxHistogram < d)
			maxHistogram = d;
	maxHistogram *= 1.05;

	plot = new Plot(plotTitle, plotXTitle, plotYTitle, xValues, yValues, Plot.X_NUMBERS + Plot.Y_NUMBERS +
			Plot.X_TICKS + Plot.Y_TICKS);

	// Ensure the horizontal scale goes from 0 to 1 but add at least 0.05 to the limits.
	double xMin = Math.min(xValues[0] - 0.05, Math.min(sampleValue - 0.05, 0));
	double xMax = Math.max(xValues[xValues.length - 1] + 0.05, Math.max(sampleValue + 0.05, 1));
	plot.setLimits(xMin, xMax, 0, maxHistogram * 1.05);
	plot.setLineWidth(1);

	plot.setColor(color);
	plot.draw();

	// Draw the significance lines and add top points
	plot.drawLine(probabilityLimits[0], 0, probabilityLimits[0], maxHistogram);
	plot.drawLine(probabilityLimits[1], 0, probabilityLimits[1], maxHistogram);

	// Draw lines for the lower and upper probability limits 
	double[][] markers = new double[2][2];
	markers[0][0] = probabilityLimits[0];
	markers[0][1] = probabilityLimits[1];
	markers[1][0] = maxHistogram;
	markers[1][1] = maxHistogram;
	plot.addPoints(markers[0], markers[1], 4);

	// Draw line for the data value 
	double[][] valueMarker = new double[2][1];
	valueMarker[0][0] = sampleValue;
	valueMarker[1][0] = maxHistogram;
	plot.setColor(Color.magenta);
	plot.drawLine(sampleValue, 0, sampleValue, maxHistogram);
	plot.addPoints(valueMarker[0], valueMarker[1], 0);
}
 
开发者ID:aherbert,项目名称:GDSC,代码行数:45,代码来源:PlotResults.java

示例4: showHistogram

import ij.gui.Plot; //导入方法依赖的package包/类
private void showHistogram(float[] h, int[] thresholds, int minbin, String title)
{
	int NGRAY = h.length;
	
	// X-axis values
	float[] bin = new float[NGRAY];
	
	// Calculate the maximum
	float hmax = 0.f;
	int mode = 0;
	for (int i = 0; i < NGRAY; ++i)
	{
		bin[i] = i + minbin;
		if (hmax < h[i])
		{
			hmax = h[i];
			mode = i;
		}
	}

	// Clip histogram to exclude the mode count as per the ij.gui.HistogramWindow.
	// For example this removes a large peak at zero in masked images.
	float hmax2 = 0; // Second highest point
	for (int i = 0; i < h.length; i++)
	{
		if (hmax2 < h[i] && i != mode)
		{
			hmax2 = h[i];
		}
	}
	if ((hmax > (hmax2 * 2)) && (hmax2 != 0))
	{
		// Set histogram limit to 50% higher than the second largest value
		hmax = hmax2 * 1.5f;
	}

	if (title == null)
		title = "Histogram";
	Plot histogram = new Plot(title, "Intensity", "p(Intensity)", bin, h);
	histogram.setLimits(minbin, minbin + NGRAY, 0.f, hmax);
	histogram.draw();
	
	// Add lines for each threshold
	histogram.setLineWidth(1);
	histogram.setColor(Color.red);
	for (int i=1; i<thresholds.length; i++)
	{
		double x = thresholds[i];
		histogram.drawLine(x, 0, x, hmax);
	}		
	
	histogram.show();
}
 
开发者ID:aherbert,项目名称:GDSC,代码行数:54,代码来源:Multi_OtsuThreshold.java


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