00001 package Encoder;
00002
00003 import java.util.ArrayList;
00004
00005 import junit.framework.Assert;
00006
00007 import Algorithms.*;
00008 import ImageStuff.GenericEdge;
00009 import ImageStuff.GeometricObject;
00010 import ImageStuff.Image;
00011 import ImageStuff.Loc;
00012 import ImageStuff.Pixel;
00013 import ImageStuff.Vertex;
00014 import ImageStuff.util.myVector;
00015 import NormalMeshAlgorithm.Configuration;
00016
00017
00018 public class EncoderEdge extends GenericEdge {
00019
00020
00021
00022
00023
00024 private Image image;
00025
00026
00027
00028
00029 public EncoderEdge(Vertex a, Vertex b, Image image, int [][] lijn,Configuration configuration) {
00030 super(a,b,lijn,configuration);
00031 this.image=image;
00032
00033
00034 }
00035
00036 public EncoderEdge(Vertex a, Vertex b,Configuration configuration) {
00037 super(a,b,configuration);
00038 }
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 public float get_l_2_norm() {
00049 int l_2_norm = 0;
00050 for (int i = 0; i != lijn.length; i++) {
00051 l_2_norm += Math.pow(getFunctiewaardeOn(i)
00052 - image.getPuntOpEnty(this.getLoc(i)).getZ(),
00053 2);
00054 }
00055 return (float) Math.sqrt(l_2_norm);
00056 }
00057
00058
00059
00060
00061
00062
00063
00064
00065 public Pixel getPredictionPixel(){
00066 return new Pixel(getMidLoc().getX(),getMidLoc().getY(),getFundamentenWaardeOn(getMiddenIndex()));
00067 }
00068
00069
00070
00076 public Pixel getPixel(int index) {
00077
00078 if (index == 0) {
00079 return getBegin();
00080 }
00081 if (index == this.getLengte() - 1) {
00082 return getEind();
00083 }
00084 return image.getPuntOpEnty(getLoc(index));
00085 }
00086
00091 public boolean onBoundary() {
00092 int x_b = getBegin().getX();
00093 int y_b = getBegin().getY();
00094 int x_e = getEind().getX();
00095 int y_e = getEind().getY();
00096 int MAXY = image.yresolutie - 1;
00097 int MAXX = image.xresolutie - 1;
00098 boolean result = (x_b == 0 && x_e == 0) || (x_b == MAXX && x_e == MAXX)
00099 || (y_b == 0 && y_e == 0) || (y_b == MAXY && y_e == MAXY);
00100 if (result) {
00101 Debug.print("on boundary!");
00102 }
00103 return result;
00104 }
00105
00106
00107
00108
00109
00110
00111 }