00001 package commandline.Encoder;
00002
00003 import commandline.ImageStuff.Image;
00004 import commandline.ImageStuff.Pixel;
00005 import commandline.ImageStuff.GeometricObjects.GenericEdge;
00006 import commandline.ImageStuff.GeometricObjects.ParametrizedPiercingVertex;
00007 import commandline.debuggingCode.Debug;
00008
00009
00010
00011 public class EncoderEdge extends GenericEdge {
00012
00013
00014
00015
00016
00017 private Image image;
00018
00019
00020
00021
00022 public EncoderEdge(ParametrizedPiercingVertex a, ParametrizedPiercingVertex b, Image image, int [][] lijn,int maxr) {
00023 super(a,b,lijn,maxr);
00024 this.image=image;
00025
00026
00027 }
00028
00029 public EncoderEdge(ParametrizedPiercingVertex a, ParametrizedPiercingVertex b,int maxr) {
00030 super(a,b,maxr);
00031 }
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 public float get_l_2_norm() {
00042 int l_2_norm = 0;
00043 for (int i = 0; i != lijn.length; i++) {
00044 l_2_norm += Math.pow(getFunctiewaardeOn(i)
00045 - image.getPuntOpEnty(this.getLoc(i)).getZ(),
00046 2);
00047 }
00048 return (float) Math.sqrt(l_2_norm);
00049 }
00050
00051
00052
00053
00054
00055
00056
00057
00058 public Pixel getPredictionPixel(){
00059 return new Pixel(getMidLoc().getX(),getMidLoc().getY(),getFundamentenWaardeOn(getMiddenIndex()));
00060 }
00061
00062
00063
00069 public Pixel getPixel(int index) {
00070
00071 if (index == 0) {
00072 return getBegin();
00073 }
00074 if (index == this.getLengte() - 1) {
00075 return getEind();
00076 }
00077 return image.getPuntOpEnty(getLoc(index));
00078 }
00079
00084 public boolean onBoundary() {
00085 int x_b = getBegin().getX();
00086 int y_b = getBegin().getY();
00087 int x_e = getEind().getX();
00088 int y_e = getEind().getY();
00089 int MAXY = image.yresolutie - 1;
00090 int MAXX = image.xresolutie - 1;
00091 boolean result = (x_b == 0 && x_e == 0) || (x_b == MAXX && x_e == MAXX)
00092 || (y_b == 0 && y_e == 0) || (y_b == MAXY && y_e == MAXY);
00093 if (result) {
00094 Debug.print("on boundary!");
00095 }
00096 return result;
00097 }
00098
00099
00100
00101
00102
00103
00104 }