本文整理汇总了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);
}
示例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));
}
}
示例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;
}