本文整理汇总了Java中org.openimaj.image.MBFImage.getHeight方法的典型用法代码示例。如果您正苦于以下问题:Java MBFImage.getHeight方法的具体用法?Java MBFImage.getHeight怎么用?Java MBFImage.getHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openimaj.image.MBFImage
的用法示例。
在下文中一共展示了MBFImage.getHeight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: projectHS
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
* Transform the Hue and Saturation components of a MBFImage by projecting
* them from a radial coordinate system to Cartesian coordinates. Assumes
* the Hue is the first band and Saturation is the second band. Any
* additional bands will be cloned to the result image.
*
* @param in
* input image
* @return Multi-band image with coupled first and second bands calculated
* by projecting from radial to Cartesian coordinates.
*/
public static MBFImage projectHS(final MBFImage in) {
if (in.colourSpace != ColourSpace.HS && in.colourSpace != ColourSpace.HSI &&
in.colourSpace != ColourSpace.HSV && in.colourSpace != ColourSpace.HSY)
throw new IllegalArgumentException("HS* colourspace is required");
final MBFImage out = in.clone();
final float[][] h = in.getBand(0).pixels;
final float[][] s = in.getBand(1).pixels;
final float[][] o1 = out.getBand(0).pixels;
final float[][] o2 = out.getBand(1).pixels;
for (int r = 0; r < in.getHeight(); r++) {
for (int c = 0; c < in.getWidth(); c++) {
o1[r][c] = (float) (s[r][c] * Math.cos(2.0 * Math.PI * h[r][c]));
o2[r][c] = (float) (s[r][c] * Math.sin(2.0 * Math.PI * h[r][c]));
}
}
out.colourSpace = ColourSpace.CUSTOM;
return out;
}
示例2: RadialDistortionCalibrator
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
* Construct the demo with the given image
* @param image the image
*/
public RadialDistortionCalibrator(MBFImage image) {
int padding = 200;
this.outImage = image.newInstance(image.getWidth() + padding, image.getHeight() + padding);
this.image = image;
this.midX = outImage.getWidth() / 2;
this.midY = outImage.getHeight() / 2;
this.origMidX = image.getWidth() / 2;
this.origMidY = image.getHeight() / 2;
this.alphaX = 0.02f;
this.alphaY = 0.04f;
this.betaX = 0.02f;
this.betaY = 0.04f;
regenAndDisplay();
createControlWindow();
}
示例3: calculateIntensityNTSC_LUT
import org.openimaj.image.MBFImage; //导入方法依赖的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;
}
示例4: updateVis
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
* {@inheritDoc}
* @see org.openimaj.vis.video.VideoBarVisualisation#updateVis(org.openimaj.image.MBFImage)
*/
@Override
public void updateVis( final MBFImage vis )
{
final float scalar = vis.getHeight() / this.frameHeight;
// Redraw each of the positions.
int frame = 0;
for( final PointList pos : this.objectPositions )
{
final PointList pp = new PointList( pos.points, true );
pp.scale( scalar );
this.drawType.draw( vis, (int)this.getTimePosition( frame ), 0, pp );
frame++;
}
}
示例5: renderOrtho
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
public void renderOrtho(Matrix transform, int tx, int ty, MBFImage image) {
final Point2dImpl pt1 = projectOrtho(transform.times(pt));
pt1.x += tx;
pt1.y += ty;
pt1.y = image.getHeight() - pt1.y;
image.drawText(text, pt1, HersheyFont.ROMAN_DUPLEX, size, colour);
}
示例6: analyseImage
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
public void analyseImage(MBFImage image) {
image.analyseWith(saliencyGenerator);
final TObjectFloatHashMap<ConnectedComponent> componentMap = saliencyGenerator.getSaliencyComponents();
final float max = ArrayUtils.maxValue(componentMap.values());
final FImage map = new FImage(image.getWidth(), image.getHeight());
final float thresh = max * alpha;
final BoundingBoxRenderer<Float> renderer = new BoundingBoxRenderer<Float>(map, 1F, true);
componentMap.forEachEntry(new TObjectFloatProcedure<ConnectedComponent>() {
@Override
public boolean execute(ConnectedComponent cc, float sal) {
if (sal >= thresh) { // note that this is reversed from the
// paper, which doesn't seem to make
// sense.
renderer.process(cc);
}
return true;
}
});
roiProportion = 0;
for (int y = 0; y < map.height; y++)
for (int x = 0; x < map.width; x++)
roiProportion += map.pixels[y][x];
roiProportion /= (map.width * map.height); // smaller simplicity means
// smaller ROI
}
示例7: calculateHue
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
* Calculate Hue in 0..1 range from a 3-band RGB MBFImage
*
* @param in
* RGB or RGBA image
* @return Hue image
*/
public static FImage calculateHue(final MBFImage in) {
if (in.colourSpace == ColourSpace.HSV)
return in.getBand(0);
if (in.colourSpace != ColourSpace.RGB && in.colourSpace != ColourSpace.RGBA)
throw new IllegalArgumentException("RGB or RGBA colourspace is required");
final FImage out = new FImage(in.getWidth(), in.getHeight());
final float[][] ra = in.getBand(0).pixels;
final float[][] ga = in.getBand(1).pixels;
final float[][] ba = in.getBand(2).pixels;
for (int rr = 0; rr < in.getHeight(); rr++) {
for (int c = 0; c < in.getWidth(); c++) {
final double r = ra[rr][c];
final double g = ga[rr][c];
final double b = ba[rr][c];
final double i = (r + g + b) / 3.0;
// from Sonka, Hlavac & Boyle; p.26
final double num = 0.5 * ((r - g) + (r - b));
final double den = Math.sqrt(((r - g) * (r - g)) + ((r - b) * (g - b)));
if (den == 0)
out.pixels[rr][c] = 0;
else
out.pixels[rr][c] = (float) Math.acos(num / den);
if ((b / i) > (g / i))
out.pixels[rr][c] = (float) ((2 * Math.PI) - out.pixels[rr][c]);
// normalise to 0..1
out.pixels[rr][c] /= 2 * Math.PI;
}
}
return out;
}
示例8: renderOrtho
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
public void renderOrtho(Matrix transform, int tx, int ty, MBFImage image) {
final Point2dImpl p1 = projectOrtho(transform.times(pt1));
p1.translate(tx, ty);
p1.y = image.getHeight() - p1.y;
final Point2dImpl p2 = projectOrtho(transform.times(pt2));
p2.translate(tx, ty);
p2.y = image.getHeight() - p2.y;
image.drawLine(p1, p2, thickness, colour);
}
示例9: RGB_TO_RGB_NORMALISED
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
* Intensity normalisation
*
* @param in
* RGB image
* @return normalised RGB image
*/
public static MBFImage RGB_TO_RGB_NORMALISED(final MBFImage in) {
final int r = in.getHeight();
final int c = in.getWidth();
final MBFImage out = new MBFImage(c, r, ColourSpace.RGB_INTENSITY_NORMALISED);
final float max = (float) Math.sqrt(3);
final float grey = (1.0f / max);
for (int j = 0; j < r; j++) {
for (int i = 0; i < c; i++) {
final Float[] pixin = in.getPixel(i, j);
if (pixin[0] == pixin[1] && pixin[1] == pixin[2] && pixin[0] == 0.0) {
out.setPixel(i, j, new Float[] { grey, grey, grey });
}
else if (pixin[0] == pixin[1] && pixin[1] == pixin[2] && pixin[0] == 1.0) {
out.setPixel(i, j, new Float[] { grey, grey, grey });
}
else {
final float length = (float) Math.sqrt(pixin[0] * pixin[0] + pixin[1] * pixin[1] + pixin[2]
* pixin[2]);
out.setPixel(i, j, new Float[] { (pixin[0] / length), (pixin[1] / length), (pixin[2] / length) });
}
}
}
return out;
}
示例10: drawToImage
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
public void drawToImage(MBFImage image) {
image.fill(RGBColour.WHITE);
final int nPoints = touchArray.size();
final float gridX = nPoints % (GRIDX + 1);
final float gridY = nPoints / (GRIDX + 1);
final Point2dImpl currentpoint = new Point2dImpl(
(image.getWidth() * (gridX / GRIDX)),
((image.getHeight()) * (gridY / GRIDY))
);
drawTarget(image, currentpoint);
}
示例11: RGB_TO_CIEXYZ
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
* CIE_XYZ color space transform from RGB. Uses inverse sRGB companding for
* energy normalisation and assumes a D65 whitepoint.
*
* Transform described here:
* http://www.brucelindbloom.com/Eqn_RGB_to_XYZ.html
*
* @param in
* input RGB image
* @return CIEXYZ image
*/
public static MBFImage RGB_TO_CIEXYZ(final MBFImage in) {
final int height = in.getHeight();
final int width = in.getWidth();
final MBFImage out = new MBFImage(width, height, ColourSpace.CIE_XYZ);
final FImage Rb = in.getBand(0);
final FImage Gb = in.getBand(1);
final FImage Bb = in.getBand(2);
final FImage Xb = out.getBand(0);
final FImage Yb = out.getBand(1);
final FImage Zb = out.getBand(2);
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
final float R = Rb.pixels[y][x];
final float G = Gb.pixels[y][x];
final float B = Bb.pixels[y][x];
// inverse sRGB companding
final double r = (R <= 0.04045) ? (R / 12.92) : (Math.pow((R + 0.055) / 1.055, 2.4));
final double g = (G <= 0.04045) ? (G / 12.92) : (Math.pow((G + 0.055) / 1.055, 2.4));
final double b = (B <= 0.04045) ? (B / 12.92) : (Math.pow((B + 0.055) / 1.055, 2.4));
// XYZ linear transform
Xb.pixels[y][x] = (float) (r * 0.4124564 + g * 0.3575761 + b * 0.1804375);
Yb.pixels[y][x] = (float) (r * 0.2126729 + g * 0.7151522 + b * 0.0721750);
Zb.pixels[y][x] = (float) (r * 0.0193339 + g * 0.1191920 + b * 0.9503041);
}
}
return out;
}
示例12: add
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
public void add(MBFImage img) {
if (img.getWidth() < 10 || img.getHeight() < 10)
return;
if (this.displayList.size() == (GRID_NX * GRID_NY + 1)) {
this.displayList.removeLast();
}
this.displayList.addFirst(img);
this.redraw();
}
示例13: CIELab_TO_CIEXYZ
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
private static MBFImage CIELab_TO_CIEXYZ(final MBFImage input, final boolean norm) {
final double epsilon = 0.008856; // actual CIE standard
final double kappa = 903.3; // actual CIE standard
final double Xr = 0.950456; // reference white
final double Yr = 1.0; // reference white
final double Zr = 1.088754; // reference white
final int height = input.getHeight();
final int width = input.getWidth();
final MBFImage out = new MBFImage(width, height, ColourSpace.CIE_XYZ);
final FImage Lb = input.getBand(0);
final FImage ab = input.getBand(1);
final FImage bb = input.getBand(2);
final FImage Xb = out.getBand(0);
final FImage Yb = out.getBand(1);
final FImage Zb = out.getBand(2);
final float Lscale = norm ? 100 : 1;
final float ascale = norm ? 256 : 1;
final float bscale = norm ? 256 : 1;
final float abdelta = norm ? -127 : 0;
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
final float L = (Lb.pixels[y][x] * Lscale);
final float a = (ab.pixels[y][x] * ascale) + abdelta;
final float b = (bb.pixels[y][x] * bscale) + abdelta;
final double fy = (L + 16) / 116;
final double fx = a / 500 + fy;
final double fz = fy - (b / 200);
final double fx3 = fx * fx * fx;
final double fz3 = fz * fz * fz;
final double xr = (fx3 > epsilon) ? fx3 : (116 * fx - 16) / kappa;
final double yr = (L > kappa * epsilon) ? Math.pow((L + 16) / 116, 3) : L / kappa;
final double zr = (fz3 > epsilon) ? fz3 : (116 * fz - 16) / kappa;
Xb.pixels[y][x] = (float) (Xr * xr);
Yb.pixels[y][x] = (float) (Yr * yr);
Zb.pixels[y][x] = (float) (Zr * zr);
}
}
return out;
}
示例14: extractContent
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
* Extract content.
* @throws IOException
*/
public void extractContent() throws IOException {
if (!extractor.load(url)) {
System.err.println("Error loading page: " + url);
System.exit(1);
}
if (layoutFile != null) writeLayout();
if (thumbnailFile != null) {
MBFImage image = getRender();
//crop first if its very long
if (image.getHeight() > 1.5 * image.getWidth()) {
image = image.extractROI(0, 0, image.getWidth(), image.getWidth());
}
MBFImage thumb = image.process(new ResizeProcessor(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT));
ImageUtilities.write(thumb, thumbnailFile);
}
if (renderFile != null) {
ImageUtilities.write(getRender(), renderFile);
}
if (layoutRender != null) {
ImageUtilities.write(extractor.renderLayoutInfo(RGBColour.BLACK), layoutRender);
}
if (layoutRenderOverlayed != null) {
ImageUtilities.write(extractor.renderLayoutInfo(getRender(), RGBColour.RED), layoutRenderOverlayed);
}
if (contentLayoutRender != null) {
ImageUtilities.write(extractor.renderContentLayout(CONTENT_COLOUR, NON_CONTENT_INSIDE_COLOUR, NON_CONTENT_COLOUR), contentLayoutRender);
}
if (contentLayoutRenderOverlayed != null) {
ImageUtilities.write(extractor.renderContentLayout(getRender(), CONTENT_COLOUR, NON_CONTENT_INSIDE_COLOUR, NON_CONTENT_COLOUR), contentLayoutRenderOverlayed);
}
}
示例15: CIELUV_TO_CIEXYZ
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
* Convert CIELUV to CIEXYZ. See <a
* href="http://www.brucelindbloom.com/Eqn_Lab_to_XYZ.html">
* http://www.brucelindbloom.com/Eqn_Lab_to_XYZ.html</a>
*
* @param input
* input image
* @return converted image
*/
public static MBFImage CIELUV_TO_CIEXYZ(final MBFImage input) {
final double epsilon = 0.008856; // actual CIE standard
final double kappa = 903.3; // actual CIE standard
final double Xr = 0.950456; // reference white
final double Yr = 1.0; // reference white
final double Zr = 1.088754; // reference white
final int height = input.getHeight();
final int width = input.getWidth();
final MBFImage out = new MBFImage(width, height, ColourSpace.CIE_XYZ);
final FImage Lb = input.getBand(0);
final FImage ub = input.getBand(1);
final FImage vb = input.getBand(2);
final FImage Xb = out.getBand(0);
final FImage Yb = out.getBand(1);
final FImage Zb = out.getBand(2);
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
final float L = Lb.pixels[y][x];
final float u = ub.pixels[y][x];
final float v = vb.pixels[y][x];
double Y;
if (L > kappa * epsilon) {
Y = Yr * Math.pow(((L + 16) / 116), 3);
} else {
Y = Yr * L / kappa;
}
final double u0 = (4 * Xr) / (Xr + 15 * Yr + 3 * Zr);
final double v0 = (9 * Yr) / (Xr + 15 * Yr + 3 * Zr);
final double a = (1.0 / 3.0) * (((52 * L) / (u + 13 * L * u0)) - 1);
final double b = -5 * Y;
final double c = -1.0 / 3.0;
final double d = Y * (((39 * L) / (v + 13 * L * v0)) - 5);
final double X = (d - b) / (a - c);
final double Z = X * a + b;
Xb.pixels[y][x] = (float) X;
Yb.pixels[y][x] = (float) Y;
Zb.pixels[y][x] = (float) Z;
}
}
return out;
}