/** * 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); }
@Override public Pixel copy() { return clone(); }
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 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); } }
static List<ConnectedComponent> findComponents(FImage image) { final DisjointSetForest<Pixel> forest = new DisjointSetForest<Pixel>(); Pixel current = new Pixel(); Pixel next = new Pixel(); for (int y = 0; y < image.height; y++) { for (int x = 0; x < image.width; x++) { current = current.clone(); next = next.clone();
@Override public Pixel transform(Matrix transform) { if (transform.getRowDimension() == 3) { float xt = (float) transform.get(0, 0) * getX() + (float) transform.get(0, 1) * getY() + (float) transform.get(0, 2); float yt = (float) transform.get(1, 0) * getX() + (float) transform.get(1, 1) * getY() + (float) transform.get(1, 2); final float zt = (float) transform.get(2, 0) * getX() + (float) transform.get(2, 1) * getY() + (float) transform.get(2, 2); xt /= zt; yt /= zt; return new Pixel(Math.round(xt), Math.round(yt)); } else if (transform.getRowDimension() == 2) { final float xt = (float) transform.get(0, 0) * getX() + (float) transform.get(0, 1) * getY(); final float yt = (float) transform.get(1, 0) * getX() + (float) transform.get(1, 1) * getY(); return new Pixel(Math.round(xt), Math.round(yt)); } throw new IllegalArgumentException("Transform matrix has unexpected size"); }
public static void main(String[] a) { Picture p; // constructor is a method - but seems you instantiate it in next line p =new Picture(FileChooser.pickAFile( )); // assign it to p Pixel pixRef = new Pixel(); //avoid nullpointerexception! but logically you should get the pixel from the picture, which displayed in next line, can remove the "new Pixel()"; pixRef = p.getPixel(2,3); // Shouldn't you get pixelref from picture? pixRef.setColor(java.awt.Color.Black); p.show(); // I don't understand this. Where do you show this? shouldn't you put it inside a Frame or something? }
if (from.equals(to)) return null; if (from.y == to.y) {
static List<ConnectedComponent> findComponents(FImage image) { final DisjointSetForest<Pixel> forest = new DisjointSetForest<Pixel>(); Pixel current = new Pixel(); Pixel next = new Pixel(); for (int y = 0; y < image.height; y++) { for (int x = 0; x < image.width; x++) { current = current.clone(); next = next.clone();
@Override public Pixel transform(Matrix transform) { if (transform.getRowDimension() == 3) { float xt = (float) transform.get(0, 0) * getX() + (float) transform.get(0, 1) * getY() + (float) transform.get(0, 2); float yt = (float) transform.get(1, 0) * getX() + (float) transform.get(1, 1) * getY() + (float) transform.get(1, 2); final float zt = (float) transform.get(2, 0) * getX() + (float) transform.get(2, 1) * getY() + (float) transform.get(2, 2); xt /= zt; yt /= zt; return new Pixel(Math.round(xt), Math.round(yt)); } else if (transform.getRowDimension() == 2) { final float xt = (float) transform.get(0, 0) * getX() + (float) transform.get(0, 1) * getY(); final float yt = (float) transform.get(1, 0) * getX() + (float) transform.get(1, 1) * getY(); return new Pixel(Math.round(xt), Math.round(yt)); } throw new IllegalArgumentException("Transform matrix has unexpected size"); }
@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); } }
if (from.equals(to)) return null; if (from.y == to.y) {
/** * {@inheritDoc} */ @Override public Pixel clone() { return new Pixel(x, y); }
@Override public Pixel copy() { return clone(); }