當前位置: 首頁>>代碼示例>>Java>>正文


Java FImageGradients.getGradientMagnitudesAndOrientations方法代碼示例

本文整理匯總了Java中org.openimaj.image.processing.convolution.FImageGradients.getGradientMagnitudesAndOrientations方法的典型用法代碼示例。如果您正苦於以下問題:Java FImageGradients.getGradientMagnitudesAndOrientations方法的具體用法?Java FImageGradients.getGradientMagnitudesAndOrientations怎麽用?Java FImageGradients.getGradientMagnitudesAndOrientations使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.openimaj.image.processing.convolution.FImageGradients的用法示例。


在下文中一共展示了FImageGradients.getGradientMagnitudesAndOrientations方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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) {
	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

示例3: 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


注:本文中的org.openimaj.image.processing.convolution.FImageGradients.getGradientMagnitudesAndOrientations方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。