當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。