本文整理汇总了Java中org.openimaj.image.FImage类的典型用法代码示例。如果您正苦于以下问题:Java FImage类的具体用法?Java FImage怎么用?Java FImage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FImage类属于org.openimaj.image包,在下文中一共展示了FImage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: run
import org.openimaj.image.FImage; //导入依赖的package包/类
@Override
public void run() {
final FImage fImage = ImageUtilities.createFImage(buffImg);
final List<KEDetectedFace> faces = DETECTOR.detectFaces(fImage);
if(!faces.isEmpty()){
CameraManager.INSTANCE.addFaces(faces.size());
final MBFImage mbf = ImageUtilities.createMBFImage(buffImg, true);
LOG.info("Found {} faces at {}", faces.size(), when);
faces.stream().forEach(f -> KERenderer.drawDetectedFace(mbf, 5, f));
final String filename = Formats.toTaken(when) + ".jpeg";
final Path outPath = ImagesEndpoint.getIMAGES_ROOT().resolve(filename);
try(OutputStream out = Files.newOutputStream(outPath)){
ImageUtilities.write(mbf, "JPG", out);
} catch (IOException ex) {
LOG.warn("Error scanning for faces", ex);
}
}
}
开发者ID:erikcostlow,项目名称:PiCameraProject,代码行数:19,代码来源:FaceScanTask.java
示例2: main
import org.openimaj.image.FImage; //导入依赖的package包/类
/**
* Test the distance transform
* @param args
* @throws IOException
*/
public static void main(String args[]) throws IOException{
FImage i = ImageUtilities.readF(new File("/Users/ss/Desktop/tache.jpg"));
EuclideanDistanceTransform etrans = new EuclideanDistanceTransform();
// i.processInplace(new CannyEdgeDetector());
i.inverse();
for(int x = 0;x < i.width; x++)
for(int y = 0; y < i.height; y++)
if(i.pixels[y][x] == 1.0f)
i.setPixel(x, y, Float.MAX_VALUE);
DisplayUtilities.display(i);
i.analyseWith(etrans);
i = etrans.getDistances();
i.normalise();
DisplayUtilities.display(i);
}
开发者ID:openimaj,项目名称:openimaj,代码行数:21,代码来源:EuclideanDistanceTransform.java
示例3: responseAt
import org.openimaj.image.FImage; //导入依赖的package包/类
/**
* Return the kernel response at the x,y in the given image.
*
* This method will throw an array index out of bounds if x,y requests
* pixels outside the image bounds
*
* @param x
* @param y
* @param image
* @return the kernel response at the given coordinates
*/
public float responseAt(int x, int y, FImage image) {
float sum = 0;
final int kh = kernel.height;
final int kw = kernel.width;
final int hh = kh / 2;
final int hw = kw / 2;
for (int j = 0, jj = kh - 1; j < kh; j++, jj--) {
for (int i = 0, ii = kw - 1; i < kw; i++, ii--) {
final int rx = x + i - hw;
final int ry = y + j - hh;
sum += image.pixels[ry][rx] * kernel.pixels[jj][ii];
}
}
return sum;
}
开发者ID:openimaj,项目名称:openimaj,代码行数:29,代码来源:FConvolution.java
示例4: beforeUpdate
import org.openimaj.image.FImage; //导入依赖的package包/类
@Override
public void beforeUpdate(MBFImage frame) {
if(learnMode){
System.out.println("Adding frame");
if(this.learningFrames.size()>5)
this.learningFrames.remove(0);
this.learningFrames.add(frame.process(new PolygonExtractionProcessor<Float[],MBFImage>(this.polygonListener.getPolygon(),RGBColour.BLACK)));
}
if(viewMode){
FImage guess = this.hmodel.classifyImage(frame).normalise();
// FImage greyFrame = Transforms.calculateIntensity(frame);
// for(int y = 0; y < guess.height; y++){
// for(int x = 0; x < guess.width; x++){
// if(guess.pixels[y][x] < 0.1){
// Float greyP = greyFrame.getPixel(x, y);
// frame.setPixel(x, y, new Float[]{greyP,greyP,greyP});
// }
//
// }
// }
frame.internalAssign(new MBFImage(new FImage[]{guess, guess, guess}));
}
this.polygonListener.drawPoints(frame);
}
开发者ID:openimaj,项目名称:openimaj,代码行数:27,代码来源:VideoPatchHistogram.java
示例5: main
import org.openimaj.image.FImage; //导入依赖的package包/类
/**
* Main method
*
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
final VideoCapture vc = new VideoCapture(320, 240);
final VideoDisplay<MBFImage> vd = VideoDisplay.createVideoDisplay(vc);
vd.addVideoListener(
new VideoDisplayListener<MBFImage>() {
@Override
public void beforeUpdate(MBFImage frame) {
final FaceDetector<DetectedFace, FImage> fd = new HaarCascadeDetector(40);
final List<DetectedFace> faces = fd.detectFaces(Transforms.calculateIntensity(frame));
for (final DetectedFace face : faces) {
frame.drawShape(face.getBounds(), RGBColour.RED);
}
}
@Override
public void afterUpdate(VideoDisplay<MBFImage> display) {
}
});
}
开发者ID:openimaj,项目名称:openimaj,代码行数:27,代码来源:App.java
示例6: main
import org.openimaj.image.FImage; //导入依赖的package包/类
public static void main(String[] args) throws IOException, InterruptedException {
final FImage[] sequence = new FImage[10];
for (int i = 0; i < sequence.length; i++) {
sequence[i] = ImageUtilities.readF(new File("/Users/jon/pendulum+circle+notexture/frame_" + i + ".png"));
}
final MovingEdges me = new MovingEdges(sequence, new FSobelMagnitude(), 10, 0.45f);
for (int i = 0; i < sequence.length - 2; i++) {
DisplayUtilities.display(me.heatOut[i].clone().normalise());
// DisplayUtilities.display(me.totalHeat[i].clone().normalise());
}
// for (int i = 0; i < sequence.length; i++) {
// DisplayUtilities.display(me.E[i].clone().normalise());
// }
}
开发者ID:openimaj,项目名称:openimaj,代码行数:17,代码来源:MovingEdges.java
示例7: debugLines
import org.openimaj.image.FImage; //导入依赖的package包/类
/**
* Helper function to display the image with lines
*
* @param i
* @param hl
* @param tf
* @param title
* @param lines
*/
private void debugLines(final FImage i, final Matrix tf, final String title,
final Collection<Line2d> lines)
{
// Create an image showing where the lines are
final MBFImage output = new MBFImage(i.getWidth(),
i.getHeight(), 3);
final MBFImageRenderer r = output.createRenderer(); // RenderHints.ANTI_ALIASED
// );
r.drawImage(i, 0, 0);
for (final Line2d l : lines)
{
final Line2d l2 = l.transform(tf).lineWithinSquare(output.getBounds());
// l2 can be null if it doesn't intersect with the image
if (l2 != null)
{
System.out.println(l2);
r.drawLine(l2, 2, RGBColour.RED);
}
}
DisplayUtilities.display(output, title);
}
开发者ID:openimaj,项目名称:openimaj,代码行数:34,代码来源:SkewCorrector.java
示例8: analyseImage
import org.openimaj.image.FImage; //导入依赖的package包/类
@Override
public void analyseImage(FImage image) {
CLQueue queue = context.createDefaultQueue();
CLImage2D in = CLImageConversion.convert(context, image);
CLImageFormat outFmt = new CLImageFormat(ChannelOrder.RGBA, ChannelDataType.Float);
CLImage2D out = context.createImage2D(CLMem.Usage.Output, outFmt, in.getWidth(), in.getHeight());
kernel.setArgs(in, out);
CLEvent evt = kernel.enqueueNDRange(queue, new int[] {(int) in.getWidth(), (int) in.getHeight()});
MBFImage res = CLImageConversion.convert(queue, evt, out, new MBFImage(image.width, image.height, 4));
this.magnitude = res.bands.get(0);
this.orientation = res.bands.get(1);
this.gradientX = res.bands.get(2);
this.gradientY = res.bands.get(3);
in.release();
out.release();
queue.release();
}
开发者ID:openimaj,项目名称:openimaj,代码行数:24,代码来源:CLSobel.java
示例9: consumeFrequency
import org.openimaj.image.FImage; //导入依赖的package包/类
@Override
public void consumeFrequency(final float[] fftReal, final float[] fftImag,final int low,final int high) {
final int blockWidth = 10;
final int blockHeight = 5;
if( this.spectra == null || this.spectra.getHeight() != (high-low) * blockHeight )
{
this.spectra = new FImage( this.mbfImage.getWidth(), (high-low)*blockHeight);
}
this.spectra.shiftLeftInplace(blockWidth);
// Draw the spectra
for( int i = low; i < high; i++ )
{
final float re = fftReal[i];
final float im = fftImag[i];
float mag = (float)Math.log(Math.sqrt( re*re + im*im )+1)/5;
if( mag > 1 ) mag = 1;
this.spectra.drawShapeFilled(new Rectangle(this.spectra.getWidth()-blockWidth, this.spectra.getHeight()-(i * blockHeight), blockWidth,blockHeight), mag );
}
final MBFImage toDraw = this.mbfImage.clone();
toDraw.drawImage(new MBFImage(this.spectra,this.spectra,this.spectra), (this.mbfImage.getWidth() - this.spectra.width)/2, this.mbfImage.getHeight() - this.spectra.height);
this.ic.setImage(this.buf = ImageUtilities.createBufferedImageForDisplay( toDraw, this.buf ));
}
开发者ID:openimaj,项目名称:openimaj,代码行数:27,代码来源:AudioOutroSlide.java
示例10: 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();
}
开发者ID:openimaj,项目名称:openimaj,代码行数:18,代码来源:DrawingTest.java
示例11: firstPassDivisor
import org.openimaj.image.FImage; //导入依赖的package包/类
float firstPassDivisor(FImage image, FImage mask) {
double accum = 0;
int count = 0;
for (int y=0; y<image.height; y++) {
for (int x=0; x<image.width; x++) {
if (mask.pixels[y][x] == 1) {
double ixy = image.pixels[y][x];
accum += Math.pow(Math.abs(ixy), alpha);
count++;
}
}
}
return (float) Math.pow(accum / count, 1.0 / alpha);
}
开发者ID:openimaj,项目名称:openimaj,代码行数:18,代码来源:MaskedRobustContrastEqualisation.java
示例12: calculateIntensityNTSC_LUT
import org.openimaj.image.FImage; //导入依赖的package包/类
/**
* Calculate intensity by a weighted average of the R, G, B planes. Assumes
* planes are all in 0..1, and NTSC weighting coefficients. Assignment to
* graylevels is done using a LUT, so greys will have one of 256 discrete
* levels. The primary purpose of this is to be compatible with
* {@link FImage#FImage(int[], int, int)} and give exactly the same result.
*
* @param in
* MBFImage with 3 bands
* @return intensity image
*/
public static FImage calculateIntensityNTSC_LUT(final MBFImage in) {
if (in.colourSpace != ColourSpace.RGB && in.colourSpace != ColourSpace.RGBA)
throw new UnsupportedOperationException("Can only convert RGB or RGBA images");
final FImage out = new FImage(in.getWidth(), in.getHeight());
for (int r = 0; r < in.getHeight(); r++) {
for (int c = 0; c < in.getWidth(); c++) {
out.pixels[r][c] = ImageUtilities.BYTE_TO_FLOAT_LUT[(int) ((
0.299f * (255 * in.getBand(0).pixels[r][c]) +
0.587f * (255 * in.getBand(1).pixels[r][c]) +
0.114f * (255 * in.getBand(2).pixels[r][c])))];
}
}
return out;
}
开发者ID:openimaj,项目名称:openimaj,代码行数:29,代码来源:Transforms.java
示例13: analyseImage
import org.openimaj.image.FImage; //导入依赖的package包/类
@Override
public void analyseImage(FImage in) {
super.analyseImage(in);
final FImage[] tmpResp = responses;
responses = new FImage[9];
responses[0] = absAverage(tmpResp[L5E5], tmpResp[E5L5]);
responses[1] = absAverage(tmpResp[L5R5], tmpResp[R5L5]);
responses[2] = absAverage(tmpResp[E5S5], tmpResp[S5E5]);
responses[3] = tmpResp[S5S5].abs();
responses[4] = tmpResp[R5R5].abs();
responses[5] = absAverage(tmpResp[L5S5], tmpResp[S5L5]);
responses[6] = tmpResp[E5E5].abs();
responses[7] = absAverage(tmpResp[E5R5], tmpResp[R5E5]);
responses[8] = absAverage(tmpResp[S5R5], tmpResp[R5S5]);
for (int i = 0; i < 9; i++) {
responses[i] = responses[i].processInplace(new SumBoxFilter(macroWidth, macroHeight));
}
}
开发者ID:openimaj,项目名称:openimaj,代码行数:22,代码来源:LawsTexture.java
示例14: processImage
import org.openimaj.image.FImage; //导入依赖的package包/类
@Override
public void processImage(FImage image) {
final FImage tmpImage = new FImage(image.width, image.height);
float min;
float max;
for (int y = 0; y < image.height; y++) {
for (int x = 0; x < image.width; x++) {
min = Float.MAX_VALUE;
max = -Float.MAX_VALUE;
for (final Pixel sp : support) {
final int xx = x + sp.x;
final int yy = y + sp.y;
if (xx >= 0 && xx < image.width - 1 && yy >= 0 && yy < image.height - 1) {
min = Math.min(min, image.pixels[yy][xx]);
max = Math.max(max, image.pixels[yy][xx]);
}
}
tmpImage.pixels[y][x] = max - min;
}
}
image.internalAssign(tmpImage);
}
开发者ID:openimaj,项目名称:openimaj,代码行数:26,代码来源:LocalContrastFilter.java
示例15: render
import org.openimaj.image.FImage; //导入依赖的package包/类
protected FImage render(List<IndependentPair<String, Point2d>> pts, int sz) {
FImage image = new FImage(sz, sz);
FImageRenderer renderer = image.createRenderer(RenderHints.ANTI_ALIASED);
for (IndependentPair<String, Point2d> pair : pts) {
double x = pair.secondObject().getX();
double y = pair.secondObject().getY();
int ix = (int) Math.round((x + 0.5) * sz/2);
int iy = (int) Math.round((y + 0.5) * sz/2);
renderer.drawShapeFilled(new Circle(ix, iy, 2), 1f);
renderer.drawText(pair.firstObject(), ix+5, iy, HersheyFont.TIMES_MEDIUM, 20, 1f);
}
return image;
}
开发者ID:openimaj,项目名称:openimaj,代码行数:19,代码来源:MDS.java
示例16: 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));
}
开发者ID:openimaj,项目名称:openimaj,代码行数:25,代码来源:FixedResizeProcessorTest.java
示例17: SFMOrtho
import org.openimaj.image.FImage; //导入依赖的package包/类
public SFMOrtho(Video<FImage> video, int nFeatures) {
texture = video.getCurrentFrame().clone();
FeatureTable features = trackFeatures(video, nFeatures, false);
features = filterNonTracked(features);
pts = features.features.get(0);
final List<Triangle> tris = DelaunayTriangulator.triangulate(pts);
triangleDefs = new int[tris.size()][3];
for (int i = 0; i < tris.size(); i++) {
final Triangle t = tris.get(i);
for (int j = 0; j < 3; j++) {
triangleDefs[i][j] = pts.indexOf(t.vertices[j]);
}
}
final Matrix w = buildMeasurementMatrix(features);
factorise(w);
applyMetricConstraint();
alignWithFrame(0);
}
开发者ID:openimaj,项目名称:openimaj,代码行数:24,代码来源:SFMOrtho.java
示例18: analyseImage
import org.openimaj.image.FImage; //导入依赖的package包/类
@Override
public void analyseImage(FImage image) {
fv = new DoubleFV(nbins);
int [] counts = new int [nbins];
float stripWidth = (float)image.width / (float)nbins;
for (int y=0; y<image.height; y++) {
for (int x=0; x<image.width; x++) {
int bin = (int)(x / stripWidth);
fv.values[bin] += image.pixels[y][x];
counts[bin]++;
}
}
for (int i=0; i<nbins; i++)
fv.values[i] /= counts[i];
}
开发者ID:openimaj,项目名称:openimaj,代码行数:19,代码来源:HorizontalIntensityDistribution.java
示例19: computeSqSumIntegralImages
import org.openimaj.image.FImage; //导入依赖的package包/类
protected void computeSqSumIntegralImages(FImage img) {
final int width = img.width;
final int height = img.height;
sum = new FImage(width + 1, height + 1);
sqSum = new FImage(width + 1, height + 1);
final float[][] sumData = sum.pixels;
final float[][] sqSumData = sqSum.pixels;
for (int y = 1; y <= height; y++) {
float rowSum = 0;
float rowSumSQ = 0;
final float[] row = img.pixels[y - 1];
for (int x = 1; x <= width; x++) {
final float pix = row[x - 1];
rowSum += pix;
rowSumSQ += pix * pix;
sumData[y][x] = sumData[y - 1][x] + rowSum;
sqSumData[y][x] = sqSumData[y - 1][x] + rowSumSQ;
}
}
}
开发者ID:openimaj,项目名称:openimaj,代码行数:27,代码来源:SummedSqTiltAreaTable.java
示例20: computeMatchScore
import org.openimaj.image.FImage; //导入依赖的package包/类
@Override
protected float computeMatchScore(final FImage image, final FImage template, final int x, final int y, final Object workingSpace) {
float score = 0;
float si = 0;
final float st = (Float)workingSpace;
final float[][] imageData = image.pixels;
final float[][] templateData = template.pixels;
final int stopX = template.width + x;
final int stopY = template.height + y;
for (int yy=y, j=0; yy<stopY; yy++, j++) {
for (int xx=x, i=0; xx<stopX; xx++, i++) {
float prod = (imageData[yy][xx] * templateData[j][i]);
score += prod;
si += (imageData[yy][xx] * imageData[yy][xx]);
}
}
return (float) (score / Math.sqrt(si*st));
}
开发者ID:openimaj,项目名称:openimaj,代码行数:23,代码来源:TemplateMatcher.java
注:本文中的org.openimaj.image.FImage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论