本文整理汇总了Java中org.openimaj.image.FImage.process方法的典型用法代码示例。如果您正苦于以下问题:Java FImage.process方法的具体用法?Java FImage.process怎么用?Java FImage.process使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openimaj.image.FImage
的用法示例。
在下文中一共展示了FImage.process方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: analyseImage
import org.openimaj.image.FImage; //导入方法依赖的package包/类
@Override
public void analyseImage(FImage image) {
final FImage sharpness = image.process(sharpProcessor);
final FImage variance = image.process(varProcessor);
double Qbokeh = 0;
int validBlocks = 0;
for (int y = 0; y < sharpness.height; y++) {
for (int x = 0; x < sharpness.width; x++) {
if (variance.pixels[y][x] >= varThreshold) {
Qbokeh += sharpness.pixels[y][x] > 0.5 ? 1 : 0;
validBlocks++;
}
}
}
Qbokeh /= (validBlocks);
bokeh = (Qbokeh >= lowerBound && Qbokeh <= upperBound) ? 1 : 0;
}
示例2: testCircle
import org.openimaj.image.FImage; //导入方法依赖的package包/类
/**
* Test
*/
@Test
public void testCircle() {
final int imgWidthHeight = 200;
final FImage circleImage = new FImage(imgWidthHeight, imgWidthHeight);
final Circle c = new Circle(imgWidthHeight / 2 + 3, imgWidthHeight / 2 + 1, imgWidthHeight / 4);
circleImage.drawShapeFilled(c, 1f);
final CannyEdgeDetector det = new CannyEdgeDetector();
final FImage edgeImage = circleImage.process(det);
final HoughCircles circ = new HoughCircles(5, imgWidthHeight, 5, 360);
edgeImage.analyseWith(circ);
final List<WeightedCircle> best = circ.getBest(1);
final WeightedCircle b = best.get(0);
assertTrue(b.equals(c));
}
示例3: analyseImage
import org.openimaj.image.FImage; //导入方法依赖的package包/类
@Override
public void analyseImage(FImage image) {
final FImage limg = image.process(laplacian);
final FImage aimg = image.process(average);
final SummaryStatistics stats = new SummaryStatistics();
for (int r = 0; r < limg.height; r++) {
for (int c = 0; c < limg.width; c++) {
if (mask != null && mask.pixels[r][c] == 0)
continue;
if (aimg.pixels[r][c] != 0) {
stats.addValue(Math.abs(limg.pixels[r][c] / aimg.pixels[r][c]));
}
}
}
sharpnessVariation = stats.getStandardDeviation();
}
示例4: processImage
import org.openimaj.image.FImage; //导入方法依赖的package包/类
@Override
public void processImage(FImage image) {
final FImage contrast = image.process(new LocalContrastFilter(FilterSupport.createBlockSupport(sizeX, sizeY)));
final FImage avg = image.process(new AverageBoxFilter(sizeX, sizeY));
final float[][] cpix = contrast.pixels;
final float[][] mpix = avg.pixels;
final float[][] ipix = image.pixels;
for (int y = 0; y < image.height; y++) {
for (int x = 0; x < image.width; x++) {
if (cpix[y][x] < threshold)
ipix[y][x] = (mpix[y][x] >= 128) ? 1 : 0;
else
ipix[y][x] = (ipix[y][x] >= mpix[y][x]) ? 1 : 0;
}
}
}
示例5: processImage
import org.openimaj.image.FImage; //导入方法依赖的package包/类
@Override
public void processImage(FImage image) {
for (int i=niter; i!=0; i--) {
FImage newImage = image.process(hitAndMiss, true);
int count = 0;
for (int y=0; y<newImage.height; y++) {
for (int x=0; x<newImage.width; x++) {
if (newImage.pixels[y][x] == 1) {
count++;
image.pixels[y][x] = 0;
}
}
}
if (count == 0)
break;
}
}
示例6: analyseImage
import org.openimaj.image.FImage; //导入方法依赖的package包/类
@Override
public void analyseImage(FImage image) {
final FImage limg = image.process(laplacian);
final FImage aimg = image.process(average);
double sum = 0;
for (int r = 0; r < limg.height; r++) {
for (int c = 0; c < limg.width; c++) {
if (mask != null && mask.pixels[r][c] == 0)
continue;
if (aimg.pixels[r][c] != 0) {
sum += Math.abs(limg.pixels[r][c] / aimg.pixels[r][c]);
}
}
}
sharpness = sum / (limg.height * limg.width);
}
示例7: testFixedResize
import org.openimaj.image.FImage; //导入方法依赖的package包/类
/**
* @throws IOException
*/
@Test
public void testFixedResize() throws IOException {
final FImage image = ImageUtilities.readF(ResizeProcessorTest.class
.getResourceAsStream("/org/openimaj/image/data/sinaface.jpg"));
long start, end;
start = System.currentTimeMillis();
final FixedResizeProcessor frp = new FixedResizeProcessor(image, 500, 250);
for (int i = 0; i < 10000; i++) {
image.process(frp);
}
end = System.currentTimeMillis();
System.out.println("Time taken (fixed): " + (end - start));
final ResizeProcessor rp = new ResizeProcessor(500, 250);
start = System.currentTimeMillis();
for (int i = 0; i < 10000; i++) {
image.process(rp);
}
end = System.currentTimeMillis();
System.out.println("Time taken (normal): " + (end - start));
}
示例8: 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);
}
示例9: PyramidSet
import org.openimaj.image.FImage; //导入方法依赖的package包/类
/**
* @param image
* @param tc
*/
public PyramidSet(FImage image, TrackingContext tc) {
int nrows = image.height, ncols = image.width;
FImage floatimg2 = image.process(new FGaussianConvolve(tc.computeSmoothSigma()));
this.imgPyr = new Pyramid(ncols, nrows, (int) tc.subsampling, tc.nPyramidLevels);
this.imgPyr.computePyramid(floatimg2, tc.pyramid_sigma_fact);
this.gradx = new Pyramid(ncols, nrows, (int) tc.subsampling, tc.nPyramidLevels);
this.grady = new Pyramid(ncols, nrows, (int) tc.subsampling, tc.nPyramidLevels);
for (int i = 0 ; i < tc.nPyramidLevels ; i++)
tc.computeGradients(imgPyr.img[i], tc.grad_sigma, gradx.img[i], grady.img[i]);
}
示例10: processImage
import org.openimaj.image.FImage; //导入方法依赖的package包/类
@Override
public void processImage(FImage image) {
final FImage tmp = image.process(new FGaussianConvolve(sigma));
final float[][] tpix = tmp.pixels;
final float[][] ipix = image.pixels;
for (int y = 0; y < image.height; y++)
for (int x = 0; x < image.width; x++)
tpix[y][x] = ipix[y][x] < (tpix[y][x] - offset) ? 0f : 1f;
image.internalAssign(tmp);
}
示例11: detect
import org.openimaj.image.FImage; //导入方法依赖的package包/类
@Override
protected void detect(FImage image, SWTTextDetector detector) {
final StrokeWidthTransform swt = new StrokeWidthTransform(true, detector.options.canny);
swt.setMaxStrokeWidth(detector.options.maxStrokeWidth);
FImage swtImage = image.process(swt);
detector.analyseImage(image, swtImage);
swt.setDirection(false);
swtImage = image.process(swt);
detector.analyseImage(image, swtImage);
}
示例12: processImage
import org.openimaj.image.FImage; //导入方法依赖的package包/类
@Override
public void processImage(FImage image) {
FImage newImage = image.process(hitAndMiss, true);
for (int y=0; y<newImage.height; y++) {
for (int x=0; x<newImage.width; x++) {
if (newImage.pixels[y][x] == 1) {
image.pixels[y][x] = 1;
}
}
}
}
示例13: test90Degree
import org.openimaj.image.FImage; //导入方法依赖的package包/类
/**
* Not a good test yet, just trys to run the processor, no attempt is made
* to check the processor
*
* @throws IOException
*/
@Test
public void test90Degree() throws IOException {
final FImage img = ImageUtilities.readF(TestOrientedPolygonExtractionProcessor.class
.getResourceAsStream("/org/openimaj/image/data/bird.png"));
final Rectangle r = new Rectangle(320, 100, 60, 170);
final Polygon p = r.asPolygon();
final Polygon prot = p.clone();
final Point2d center = prot.calculateCentroid();
prot.rotate(center, Math.PI / 3);
final OrientedPolygonExtractionProcessor opep = new OrientedPolygonExtractionProcessor(prot, 0.f);
img.process(opep);
}
示例14: main
import org.openimaj.image.FImage; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
final FImage img = ImageUtilities
.readF(new File(
"/Users/jon/Library/Containers/com.apple.mail/Data/Library/Mail Downloads/BD5C21CA-CC93-4C38-A96D-A44E961C5544/in-2.jpg"));
// blur the image, with more blur in the horizontal direction than
// vertical
final FImage i1 = img.process(new AverageBoxFilter(40, 10));
// numerical issues from the way the box filter is implemented might
// mean that there are values slightly bigger than 1, so clip the values
// to a maximum of 1.
i1.clip(0f, 1f);
// threshold the image to make it purely black and white
i1.processInplace(new OtsuThreshold());
// invert the image before input to the ConnectedComponentLabeler
i1.inverse();
// Apply connected component labelling to find all the "blobs"
final ConnectedComponentLabeler ccl = new ConnectedComponentLabeler(ConnectMode.CONNECT_8);
final List<ConnectedComponent> ccs = ccl.findComponents(i1);
// values for the computed bounds of the "graphic"
int left = i1.width;
int right = 0;
int top = i1.height;
int bottom = 0;
// loop through the "blobs" and filter them
for (final ConnectedComponent cc : ccs) {
final Rectangle bb = cc.calculateRegularBoundingBox();
// ignore components that are near the top edge
if (bb.y < 0.1 * i1.height)
continue;
// ignore components that are near the right edge
if (bb.x + bb.width > 0.9 * i1.width)
continue;
// filter the other components based on their width and the relative
// area of the blob to its bounding box (should be ~1 for a text
// block)
if (bb.width < 0.4 * i1.width || bb.calculateArea() / cc.calculateArea() > 2) {
if (bb.x < left)
left = (int) bb.x;
if (bb.x + bb.width > right)
right = (int) (bb.x + bb.width);
if (bb.y < top)
top = (int) bb.y;
if (bb.y + bb.height > bottom)
bottom = (int) (bb.y + bb.height);
i1.drawShape(bb, 0.5f);
}
}
// construct the final bounds rectangle (might want to extend/pad it)
final Rectangle bounds = new Rectangle(left, top, right - left, bottom - top);
DisplayUtilities.display(img.extractROI(bounds));
}
示例15: segment
import org.openimaj.image.FImage; //导入方法依赖的package包/类
@Override
public List<ConnectedComponent> segment(FImage image) {
final FImage timg = image.process(thresholder);
return algorithm.findComponents(timg, 0, mode);
}