本文整理汇总了Java中org.openimaj.image.FImage.addInplace方法的典型用法代码示例。如果您正苦于以下问题:Java FImage.addInplace方法的具体用法?Java FImage.addInplace怎么用?Java FImage.addInplace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openimaj.image.FImage
的用法示例。
在下文中一共展示了FImage.addInplace方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadPositive
import org.openimaj.image.FImage; //导入方法依赖的package包/类
static FImage loadPositive() throws IOException {
final String base = "/Users/jsh2/Data/att_faces/s%d/%d.pgm";
final FImage image = new FImage(400, 400);
for (int j = 1; j <= 40; j++) {
for (int i = 1; i <= 10; i++) {
final File file = new File(String.format(base, j, i));
FImage img = ImageUtilities.readF(file);
img = img.extractCenter(50, 50);
img = ResizeProcessor.resample(img, 400, 400);
image.addInplace(img);
}
}
return image.normalise();
}
示例2: beforeUpdate
import org.openimaj.image.FImage; //导入方法依赖的package包/类
@Override
public void beforeUpdate(MBFImage frame) {
// Rectangle extractionArea = new
// Rectangle(100,100,IMAGE_WIDTH-200,IMAGE_HEIGHT-200);
if (this.mode == DebugMode.DEBUG_DISPLAY)
return;
final FImage grey = frame.extractROI(extractionArea).flatten();
if (!this.backgroundLearner.ready()) {
grey.process(this.backgroundLearner);
frame.fill(RGBColour.BLACK);
frame.drawImage(new MBFImage(grey, grey, grey), (int) extractionArea.x, (int) extractionArea.y);
return;
}
grey.addInplace(this.backgroundLearner.getBackground());
grey.threshold(0.07f);
// grey.processInplace(new OtsuThreshold());
// if(grey.sum() > BIGGEST_POINT_AREA * 2 ){
// this.backgroundLearner.relearn();
// return;
// }
// List<Circle> filtered = getFilteredCircles(grey);
final List<Touch> filtered = getFilteredTouchesFast(grey);
if (filtered.size() != 0)
this.fireTouchEvent(filtered);
frame.fill(RGBColour.BLACK);
frame.drawImage(new MBFImage(grey, grey, grey), (int) extractionArea.x, (int) extractionArea.y);
}
示例3: testConsistency
import org.openimaj.image.FImage; //导入方法依赖的package包/类
/**
* Test consistency between modes.
*/
@Test
public void testConsistency() {
FImage kernel = new FImage(3,3);
kernel.addInplace(1f);
FImage kernelRow = new FImage(3,1);
FImage kernelCol = new FImage(1,3);
kernelRow.addInplace(3f);
kernelCol.addInplace(3f);
FImage im = new FImage(10,10);
im.addInplace(1f);
FConvolution conAutoSep = new FConvolution(kernel);
FConvolution conBrute = new FConvolution(kernel);
FConvolution conAutoRow = new FConvolution(kernelRow);
FConvolution conAutoCol = new FConvolution(kernelCol);
conBrute.setBruteForce(true);
assertTrue(im.process(conAutoSep).equalsThresh(im.multiply(9f), 0.001f));
assertTrue(im.process(conAutoRow).equalsThresh(im.multiply(9f), 0.001f));
assertTrue(im.process(conAutoCol).equalsThresh(im.multiply(9f), 0.001f));
assertTrue(im.process(conBrute).extractROI(1, 1, im.width-3, im.height-3).equalsThresh(im.multiply(9f).extractROI(1, 1, im.width-3, im.height-3), 0.001f));
}
示例4: process
import org.openimaj.image.FImage; //导入方法依赖的package包/类
/**
* {@inheritDoc}
* @see org.openimaj.image.analysis.pyramid.PyramidProcessor#process(org.openimaj.image.analysis.pyramid.gaussian.GaussianPyramid)
*/
@Override
public void process( final GaussianPyramid<FImage> pyramid )
{
FImage fmap = null;
// Process each of the octaves in the pyramid
for( final GaussianOctave<FImage> octave : pyramid )
{
// Extract text regions using the basic text extractor
FImage octaveFMap = LiuSamarabanduTextExtractorMultiscale.this.basicTextExtractor.textRegionDetection(
octave.getNextOctaveImage() );
if( fmap == null )
fmap = octaveFMap;
else
{
// Fuse across scales
octaveFMap = ResizeProcessor.resample( octaveFMap,
fmap.getWidth(), fmap.getHeight() ).normalise();
if( LiuSamarabanduTextExtractorMultiscale.DEBUG )
DisplayUtilities.display( octaveFMap, "Resized feature map" );
fmap.addInplace( octaveFMap );
}
}
this.featureMap = fmap;
}
示例5: createInterestPointMap
import org.openimaj.image.FImage; //导入方法依赖的package包/类
@Override
public FImage createInterestPointMap() {
FImage lxx = l.process(BasicDerivativeKernels.DXX_KERNEL).multiplyInplace(detectionScale*detectionScale);
FImage lyy = l.process(BasicDerivativeKernels.DYY_KERNEL).multiplyInplace(detectionScale*detectionScale);
FImage add = lxx.addInplace(lyy);
return add.multiply(add);
}
示例6: main
import org.openimaj.image.FImage; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
final TestImageClass tic = new TestImageClass();
final FImage trainPhoto = ResizeProcessor.halfSize(ResizeProcessor.halfSize(ImageUtilities.readF(new File(
"/Users/jon/Desktop/images50cm4band/sp7034.jpeg"))));
final FImage trainClass = ResizeProcessor.halfSize(ResizeProcessor.halfSize(ImageUtilities.readF(new File(
"/Users/jon/Desktop/images50cm4band/sp7034-classes.PNG"))));
tic.extractFeaturePatches(trainPhoto, 20000, 8);
tic.extractClassifierTrainingPatches(trainPhoto, trainClass, 1000, 32);
tic.learnDictionary(100);
// Note: should really use sparse version!!
/*
* final LiblinearAnnotator<FImage, Boolean> ann = new
* LiblinearAnnotator<FImage, Boolean>(tic, Mode.MULTICLASS,
* SolverType.L2R_L2LOSS_SVC, 1, 0.0001);
*
* final MapBackedDataset<Boolean, ListBackedDataset<FImage>, FImage>
* data = new MapBackedDataset<Boolean, ListBackedDataset<FImage>,
* FImage>(); data.add(true, new
* ListBackedDataset<FImage>(Arrays.asList(tic.ruralPatches)));
* data.add(false, new
* ListBackedDataset<FImage>(Arrays.asList(tic.urbanPatches)));
* ann.train(data);
*/
final FImage test = ResizeProcessor.halfSize(ResizeProcessor.halfSize(ImageUtilities.readF(new File(
"/Users/jon/Desktop/images50cm4band/test.jpeg")))).normalise();
/*
* final FImage result = test.extractCenter(test.width - 32, test.height
* - 32); final FImage tmp = new FImage(32, 32); for (int y = 0; y <
* test.height - 32; y++) { for (int x = 0; x < test.width - 32; x++) {
* test.extractROI(x, y, tmp);
*
* final ClassificationResult<Boolean> r = ann.classify(tmp); final
* Boolean clz = r.getPredictedClasses().iterator().next();
*
* if (clz) result.pixels[y][x] = 1;
*
* DisplayUtilities.displayName(result, "result"); } }
*/
final FImage tmp = new FImage(8 * 10, 8 * 10);
for (int i = 0, y = 0; y < 10; y++) {
for (int x = 0; x < 10; x++, i++) {
final FImage p = new FImage(tic.dictionary[i], 8, 8);
p.divideInplace(2 * Math.max(p.min(), p.max()));
p.addInplace(0.5f);
tmp.drawImage(p, x * 8, y * 8);
}
}
DisplayUtilities.display(tmp);
}
示例7: main
import org.openimaj.image.FImage; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
final File patchesFile = new File("patches.bin");
// final RandomPatchSampler sampler =
// new
// RandomPatchSampler(Caltech101.getImages(ImageUtilities.FIMAGE_READER),
// 8, 8, 100000);
// sampler.save(patchesFile);
final List<FImage> patches = RandomPatchSampler.loadPatches(patchesFile);
final double[][] data = new double[patches.size()][];
for (int i = 0; i < data.length; i++)
data[i] = patches.get(i).getDoublePixelVector();
// final PCAWhitening whitening = new PCAWhitening();
final WhiteningTransform whitening = new ZCAWhitening(0.1, new PerExampleMeanCenterVar(10f / 255f));
whitening.train(data);
final double[][] wd = whitening.whiten(data);
// final double[][] comps =
// whitening.getTransform().transpose().getArray();
// for (int i = 0; i < comps.length; i++)
// DisplayUtilities.di play(ResizeProcessor.resample(new
// FImage(comps[i], 8, 8).normalise(), 128, 128));
// final FImage tmp1 = new FImage(100 * 8, 100 * 8);
// final FImage tmp2 = new FImage(100 * 8, 100 * 8);
// final FImage tmp3 = new FImage(100 * 8, 100 * 8);
// for (int i = 0; i < 100; i++) {
// for (int j = 0; j < 100; j++) {
// final double[] d = new PerExampleMeanCenterVar(10f /
// 255f).normalise(patches.get(i * 100 + j)
// .getDoublePixelVector());
// FImage patch = new FImage(d, 8, 8);
// patch.divideInplace(2 * Math.max(patch.min(), patch.max()));
// patch.addInplace(0.5f);
// tmp2.drawImage(patch, i * 8, j * 8);
//
// tmp3.drawImage(patches.get(i * 100 + j), i * 8, j * 8);
//
// patch = new FImage(wd[i * 100 + j], 8, 8);
// patch.divideInplace(2 * Math.max(patch.min(), patch.max()));
// patch.addInplace(0.5f);
// tmp1.drawImage(patch, i * 8, j * 8);
// }
// }
// DisplayUtilities.display(tmp3);
// DisplayUtilities.display(tmp2);
// DisplayUtilities.display(tmp1);
final SphericalKMeans skm = new SphericalKMeans(2500, 10);
final SphericalKMeansResult res = skm.cluster(wd);
final FImage tmp = new FImage(50 * (8 + 1) + 1, 50 * (8 + 1) + 1);
tmp.fill(1f);
for (int i = 0; i < 50; i++) {
for (int j = 0; j < 50; j++) {
final FImage patch = ResizeProcessor
.resample(
new FImage(res.centroids[i * 50 + j], 8, 8),
8, 8);
patch.divideInplace(2 * Math.max(Math.abs(patch.min()),
Math.abs(patch.max())));
patch.addInplace(0.5f);
tmp.drawImage(patch, i * (8 + 1) + 1, j * (8 + 1) + 1);
}
}
DisplayUtilities.display(tmp);
}