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


Java FImageGradients类代码示例

本文整理汇总了Java中org.openimaj.image.processing.convolution.FImageGradients的典型用法代码示例。如果您正苦于以下问题:Java FImageGradients类的具体用法?Java FImageGradients怎么用?Java FImageGradients使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FImageGradients类属于org.openimaj.image.processing.convolution包,在下文中一共展示了FImageGradients类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setup

import org.openimaj.image.processing.convolution.FImageGradients; //导入依赖的package包/类
/**
 * Setup tests
 * 
 * @throws IOException
 */
@Before
public void setup() throws IOException {
	image = ImageUtilities.readF(OpenIMAJ.getLogoAsStream());

	final Mode mode = FImageGradients.Mode.Unsigned;

	final FImage[] interpMags = new FImage[9];
	final FImage[] mags = new FImage[9];
	for (int i = 0; i < 9; i++) {
		interpMags[i] = new FImage(image.width, image.height);
		mags[i] = new FImage(image.width, image.height);
	}

	FImageGradients.gradientMagnitudesAndQuantisedOrientations(image, interpMags, true, mode);
	FImageGradients.gradientMagnitudesAndQuantisedOrientations(image, mags, false, mode);

	satInterp = new SATWindowedExtractor(interpMags);
	sat = new SATWindowedExtractor(mags);

	gradMags = FImageGradients.getGradientMagnitudesAndOrientations(image, mode);
	binnedInterp = new InterpolatedBinnedWindowedExtractor(9, mode.minAngle(), mode.maxAngle(), true);
	binned = new BinnedWindowedExtractor(9, mode.minAngle(), mode.maxAngle());
	gradMags.orientations.analyseWith(binnedInterp);
	gradMags.orientations.analyseWith(binned);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:31,代码来源:SATWindowedExtractorTest.java

示例2: analyseImage

import org.openimaj.image.processing.convolution.FImageGradients; //导入依赖的package包/类
@Override
public void analyseImage(FImage image, Rectangle bounds) {
	if (data == null)
		data = new WorkingData();

	data.boundMinX = (int) bounds.x;
	data.boundMaxX = (int) (bounds.width - 1);
	data.boundMinY = (int) bounds.y;
	data.boundMaxY = (int) (bounds.height - 1);

	data.setupWorkingSpace(image, this);

	FImageGradients.gradientMagnitudesAndQuantisedOrientations(image, data.gradientMagnitudes);

	extractFeatures();

	normaliseDescriptors();
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:19,代码来源:DenseSIFT.java

示例3: beforeUpdate

import org.openimaj.image.processing.convolution.FImageGradients; //导入依赖的package包/类
@Override
public void beforeUpdate(MBFImage frame) {
	final FImage f = frame.flatten();

	f.analyseWith(sobel);
	sobel.dx.normalise();
	dyImage = sobel.dy.normalise();

	FImageGradients.gradientMagnitudesAndOrientations(f, magImage, oriImage);
	magImage.normalise();
	oriImage.normalise();

	frame.internalAssign(sobel.dx.toRGB());
	dyImageIC.setImage(dyImageB = ImageUtilities.createBufferedImage(dyImage));
	magImageIC.setImage(magImageB = ImageUtilities.createBufferedImage(magImage));
	oriImageIC.setImage(oriImageB = ImageUtilities.createBufferedImage(oriImage));
}
 
开发者ID:jonhare,项目名称:COMP3005,代码行数:18,代码来源:GradOriDemo.java

示例4: analyseImage

import org.openimaj.image.processing.convolution.FImageGradients; //导入依赖的package包/类
@Override
public void analyseImage(FImage image) {
	final FImage[] magnitudes = new FImage[nbins];

	for (int i = 0; i < nbins; i++)
		magnitudes[i] = new FImage(image.width, image.height);

	FImageGradients.gradientMagnitudesAndQuantisedOrientations(image, magnitudes, histogramInterpolation,
			orientationMode);

	computeSATs(magnitudes);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:13,代码来源:GradientOrientationHistogramExtractor.java

示例5: analyseImage

import org.openimaj.image.processing.convolution.FImageGradients; //导入依赖的package包/类
@Override
public void analyseImage(FImage image) {
	lastBounds = image.getBounds();

	final FImageGradients gradMag = FImageGradients.getGradientMagnitudesAndOrientations(image, orientationMode);
	this.magnitudes = gradMag.magnitudes;

	histExtractor.analyseImage(gradMag.orientations);

	if (edgeDetector != null) {
		magnitudes.multiplyInplace(image.process(edgeDetector));
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:14,代码来源:PHOG.java

示例6: getCurrentGradientProps

import org.openimaj.image.processing.convolution.FImageGradients; //导入依赖的package包/类
/**
 * Get the GradientScaleSpaceImageExtractorProperties for the given
 * properties. The returned properties are the same as the input properties,
 * but with the gradient images added.
 *
 * For efficiency, this method always returns the same cached
 * GradientScaleSpaceImageExtractorProperties, and internally updates this
 * as necessary. The gradient images are only recalculated when the input
 * image from the input properties is different to the cached one.
 *
 * @param properties
 *            input properties
 * @return cached GradientScaleSpaceImageExtractorProperties
 */
public GradientScaleSpaceImageExtractorProperties<FImage> getCurrentGradientProps(
		ScaleSpaceImageExtractorProperties<FImage> properties)
{
	if (properties.image != currentGradientProperties.image) {
		currentGradientProperties.image = properties.image;

		// only if the size of the image has changed do we need to reset the
		// gradient and orientation images.
		if (currentGradientProperties.orientation == null ||
				currentGradientProperties.orientation.height != currentGradientProperties.image.height ||
				currentGradientProperties.orientation.width != currentGradientProperties.image.width)
		{
			currentGradientProperties.orientation = new FImage(currentGradientProperties.image.width,
					currentGradientProperties.image.height);
			currentGradientProperties.magnitude = new FImage(currentGradientProperties.image.width,
					currentGradientProperties.image.height);
		}

		FImageGradients.gradientMagnitudesAndOrientations(currentGradientProperties.image,
				currentGradientProperties.magnitude, currentGradientProperties.orientation);
	}

	currentGradientProperties.x = properties.x;
	currentGradientProperties.y = properties.y;
	currentGradientProperties.scale = properties.scale;

	return currentGradientProperties;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:43,代码来源:GradientFeatureExtractor.java

示例7: extract

import org.openimaj.image.processing.convolution.FImageGradients; //导入依赖的package包/类
public OrientedFeatureVector[] extract(FImage image, Ellipse ellipse) {
	final Matrix tf = ellipse.transformMatrix();
	final FImage patch = new FImage(patchSize, patchSize);
	final float halfSize = patchSize / 2;

	// Sample the ellipse content into a rectified image
	for (int y = 0; y < patchSize; y++) {
		for (int x = 0; x < patchSize; x++) {
			final Point2dImpl pt = new Point2dImpl((x - halfSize) / halfSize, (y - halfSize) / halfSize);
			final Point2dImpl tpt = pt.transform(tf);
			patch.pixels[y][x] = image.getPixelInterpNative(tpt.x, tpt.y, 0);
		}
	}

	// now find grad mags and oris
	final FImageGradients gmo = FImageGradients.getGradientMagnitudesAndOrientations(patch);

	final GradientScaleSpaceImageExtractorProperties<FImage> props = new GradientScaleSpaceImageExtractorProperties<FImage>();
	props.image = patch;
	props.magnitude = gmo.magnitudes;
	props.orientation = gmo.orientations;
	props.x = patch.width / 2;
	props.y = patch.height / 2;
	props.scale = patch.height / 2 / 3; // ???

	final DominantOrientationExtractor doe = new DominantOrientationExtractor();
	final float[] oris = doe.extractFeatureRaw(props);

	final MBFImage p2 = patch.toRGB();
	for (final float o : oris) {
		p2.drawLine(p2.getWidth() / 2, p2.getHeight() / 2, o, 20, RGBColour.RED);
	}
	DisplayUtilities.display(p2);

	final OrientedFeatureVector[] vectors = new OrientedFeatureVector[oris.length];
	for (int i = 0; i < oris.length; i++) {
		final float ori = oris[i];
		final GradientFeatureProvider provider = factory.newProvider();

		// and construct the feature and sampling every pixel in the patch
		// note: the descriptor is actually computed over a sub-patch; there
		// is
		// a border that is used for oversampling and avoiding edge effects.
		final float overSample = provider.getOversamplingAmount();
		for (int y = 0; y < patchSize; y++) {
			final float yy = (y * (2 * overSample + 1) / patchSize) - overSample;

			for (int x = 0; x < patchSize; x++) {
				final float xx = (x * (2 * overSample + 1) / patchSize) - overSample;

				final float gradmag = gmo.magnitudes.pixels[y][x];
				final float gradori = gmo.orientations.pixels[y][x];
				provider.addSample(xx, yy, gradmag, gradori - ori);
			}
		}

		vectors[i] = provider.getFeatureVector();
	}

	return vectors;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:62,代码来源:EllipseGradientFeatureExtractor.java

示例8: PHOG

import org.openimaj.image.processing.convolution.FImageGradients; //导入依赖的package包/类
/**
 * Construct with the given parameters. The <code>edgeDetector</code>
 * parameter can be <code>null</code> if you don't want to filter out
 * non-edge pixels from the histograms.
 *
 * @param nlevels
 *            number of pyramid levels (note this includes l0, so you might
 *            need 1 more)
 * @param nbins
 *            number of bins
 * @param histogramInterpolation
 *            should the gradient orientations be interpolated?
 * @param orientationMode
 *            the orientation mode
 * @param edgeDetector
 *            the edge detector to use (may be <code>null</code> for
 *            gradient features)
 */
public PHOG(int nlevels, int nbins, boolean histogramInterpolation, FImageGradients.Mode orientationMode,
		ImageProcessor<FImage> edgeDetector)
{
	this.nlevels = nlevels;
	this.edgeDetector = edgeDetector;
	this.orientationMode = orientationMode;

	if (histogramInterpolation)
		histExtractor = new InterpolatedBinnedWindowedExtractor(nbins, true);
	else
		histExtractor = new BinnedWindowedExtractor(nbins);

	histExtractor.setMax(orientationMode.maxAngle());
	histExtractor.setMin(orientationMode.minAngle());
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:34,代码来源:PHOG.java

示例9: getCurrentGradientProps

import org.openimaj.image.processing.convolution.FImageGradients; //导入依赖的package包/类
/**
 * Get the GradientScaleSpaceImageExtractorProperties for the given
 * properties. The returned properties are the same as the input properties,
 * but with the gradient images added.
 *
 * For efficiency, this method always returns the same cached
 * GradientScaleSpaceImageExtractorProperties, and internally updates this
 * as necessary. The gradient images are only recalculated when the input
 * image from the input properties is different to the cached one.
 *
 * @param properties
 *            input properties
 * @return cached GradientScaleSpaceImageExtractorProperties
 */
public GradientScaleSpaceImageExtractorProperties<FImage> getCurrentGradientProps(
		ScaleSpaceImageExtractorProperties<MBFImage> properties)
{
	if (properties.image != image) {
		image = properties.image;
		currentGradientProperties.image = image.bands.get(0);

		// only if the size of the image has changed do we need to reset the
		// gradient and orientation images.
		if (currentGradientProperties.orientation == null ||
				currentGradientProperties.orientation.height != currentGradientProperties.image.height ||
				currentGradientProperties.orientation.width != currentGradientProperties.image.width)
		{
			currentGradientProperties.orientation = new FImage(currentGradientProperties.image.width,
					currentGradientProperties.image.height);
			currentGradientProperties.magnitude = new FImage(currentGradientProperties.image.width,
					currentGradientProperties.image.height);

			if (magnitudes == null) {
				magnitudes = new FImage[image.bands.size() - 1];
				orientations = new FImage[image.bands.size() - 1];
			}

			for (int i = 0; i < magnitudes.length; i++) {
				magnitudes[i] = new FImage(currentGradientProperties.image.width,
						currentGradientProperties.image.height);
				orientations[i] = new FImage(currentGradientProperties.image.width,
						currentGradientProperties.image.height);
			}
		}

		FImageGradients.gradientMagnitudesAndOrientations(currentGradientProperties.image,
				currentGradientProperties.magnitude, currentGradientProperties.orientation);

		for (int i = 0; i < magnitudes.length; i++) {
			FImageGradients.gradientMagnitudesAndOrientations(image.getBand(i + 1), magnitudes[i], orientations[i]);
		}
	}

	currentGradientProperties.x = properties.x;
	currentGradientProperties.y = properties.y;
	currentGradientProperties.scale = properties.scale;

	return currentGradientProperties;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:60,代码来源:ColourGradientFeatureExtractor.java

示例10: GradientOrientationHistogramExtractor

import org.openimaj.image.processing.convolution.FImageGradients; //导入依赖的package包/类
/**
 * Construct a new {@link GradientOrientationHistogramExtractor} with the
 * given number of bins. Optionally perform linear interpolation across
 * orientation bins. Histograms can also use either signed or unsigned
 * gradients.
 *
 * @param nbins
 *            number of bins
 * @param histogramInterpolation
 *            if true cyclic linear interpolation is used to share the
 *            magnitude across the two closest bins; if false only the
 *            closest bin will be filled.
 * @param orientationMode
 *            the range of orientations to extract
 */
public GradientOrientationHistogramExtractor(int nbins, boolean histogramInterpolation,
		FImageGradients.Mode orientationMode)
{
	super(nbins);

	this.histogramInterpolation = histogramInterpolation;
	this.orientationMode = orientationMode;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:24,代码来源:GradientOrientationHistogramExtractor.java

示例11: HOG

import org.openimaj.image.processing.convolution.FImageGradients; //导入依赖的package包/类
/**
 * Construct a new {@link HOG} with the given number of bins. Optionally
 * perform linear interpolation across orientation bins. Histograms can also
 * use either signed or unsigned gradients.
 *
 * @param nbins
 *            number of bins
 * @param histogramInterpolation
 *            if true cyclic linear interpolation is used to share the
 *            magnitude across the two closest bins; if false only the
 *            closest bin will be filled.
 * @param orientationMode
 *            the range of orientations to extract
 * @param strategy
 *            the {@link SpatialBinningStrategy} to use to produce the
 *            features
 */
public HOG(int nbins, boolean histogramInterpolation, FImageGradients.Mode orientationMode,
		SpatialBinningStrategy strategy)
{
	this.extractor = new GradientOrientationHistogramExtractor(nbins, histogramInterpolation, orientationMode);

	this.strategy = strategy;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:25,代码来源:HOG.java


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