/** * Construct a contour with the given type and start at the origin * * @param type * the type */ public Contour(ContourType type) { this.type = type; this.start = new Pixel(0, 0); }
/** * {@inheritDoc} */ @Override public Pixel clone() { return new Pixel(x, y); }
/** * {@inheritDoc} */ @Override public Pixel clone() { return new Pixel(x, y); }
private Pixel computeDelta(LetterCandidate firstObject, LetterCandidate secondObject) { final Rectangle frect = firstObject.regularBoundingBox; final Rectangle srect = secondObject.regularBoundingBox; final int dx = (int) (frect.x - srect.x + (frect.width - srect.width) / 2); final int dy = (int) (frect.y - srect.y + (frect.height - srect.height) / 2); return new Pixel(dx, dy); } });
private Pixel computeDelta(LetterCandidate firstObject, LetterCandidate secondObject) { final Rectangle frect = firstObject.regularBoundingBox; final Rectangle srect = secondObject.regularBoundingBox; final int dx = (int) (frect.x - srect.x + (frect.width - srect.width) / 2); final int dy = (int) (frect.y - srect.y + (frect.height - srect.height) / 2); return new Pixel(dx, dy); } });
/** * Construct a contour with the given type and start at the origin * * @param type * the type */ public Contour(ContourType type) { this.type = type; this.start = new Pixel(0, 0); }
for(int i=0; i<tHeigh; i++){ for(int j=0; j<tWidth; j++){ pixel[i][j] = new Pixel(); } }
/** * Calculates the centroid pixel of the connected component. That is, the * centroid value is rounded to the nearest pixel. * * @return A {@link Pixel} at the centroid. */ public Pixel calculateCentroidPixel() { final double[] centroid = calculateCentroid(); return new Pixel((int) Math.round(centroid[0]), (int) Math.round(centroid[1])); }
@Override public void mouseDragged(MouseEvent e) { final Pixel p = new Pixel(e.getX(), e.getY()); updateImage(p); }
/** * Calculates the centroid pixel of the connected component. That is, the * centroid value is rounded to the nearest pixel. * * @return A {@link Pixel} at the centroid. */ public Pixel calculateCentroidPixel() { final double[] centroid = calculateCentroid(); return new Pixel((int) Math.round(centroid[0]), (int) Math.round(centroid[1])); }
@Override public void readBinary(DataInput in) throws IOException { final int count = in.readInt(); for (int i = 0; i < count; i++) { final Pixel p = new Pixel(); p.readBinary(in); pixels.add(p); } }
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setExtendedState(JFrame.MAXIMIZED_BOTH); frame.setVisible(true); // <<-- Window becomes visible here pixel = new Pixel(1600, 900); frame.getContentPane().add(pixel); // <<-- DANGEROUS!! }
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setExtendedState(JFrame.MAXIMIZED_BOTH); pixel = new Pixel(1600, 900); frame.getContentPane().add(pixel); // <<-- Safe - window not visible yet. frame.setVisible(true); // <<-- Window becomes visible here }
public static void main(String[] args) { SwingUtilities.invokeLater( () -> { JFrame frame = new JFrame(); frame.setExtendedState(JFrame.MAXIMIZED_BOTH); frame.setVisible(true); // <<-- Window becomes visible here pixel = new Pixel(1600, 900); frame.getContentPane().add(pixel); // <<-- Safe - running on EDT. pixel.testChange(); // <<-- Also safe - running on EDT }); }
Pixel pixel = null;// neew to initialize this. pixel = new Pixel(); // somethin like this for (int x = startX; x < endX; x++){ for (int y = startY; y < endY; y++){ if (pixel.colorDistance(Color.RED) < 167){
@Override public void readASCII(Scanner in) throws IOException { final int count = in.nextInt(); for (int i = 0; i < count; i++) { final Pixel p = new Pixel(); p.readASCII(in); pixels.add(p); } }
@Override public void readASCII(Scanner in) throws IOException { final int count = in.nextInt(); for (int i = 0; i < count; i++) { final Pixel p = new Pixel(); p.readASCII(in); pixels.add(p); } }
/** * @param from * @return the pixel in the direction from some point */ public Pixel pixel(Pixel from) { return new Pixel(from.x + dirx[ordinal()], from.y + diry[ordinal()]); } }
/** * @param from * @return the pixel in the direction from some point */ public Pixel pixel(Pixel from) { return new Pixel(from.x + dirx[ordinal()], from.y + diry[ordinal()]); } }
private static boolean crossesEastBorder(final FImage image, boolean[] checked, final Pixel p) { final boolean b = checked[Direction.fromTo(p, new Pixel(p.x + 1, p.y)).ordinal()]; return image.getPixel(p) != 0 && (p.x == image.width - 1 || b);// this // is // 3.4(a) // with // an // edge // case // check }