00001 package commandline.Norm; 00002 00003 import commandline.debuggingCode.Debug; 00004 00010 public class NormenMaker { 00011 public static final int INFTY = 0 ; 00012 public static final int L_1 = 1 ; 00013 public static final int L_2 = 2 ; 00014 public static final int SOBOLEV = 3; 00015 public static final int WEIGHTED_L_2 = 4 ; 00016 00017 00018 00019 float infty; 00020 float l_1; 00021 float l_2; 00022 float sobolev; 00023 00024 00025 int aantal_pixels; 00026 00027 00033 public NormenMaker(int aantal_pixels) { 00034 this.aantal_pixels=aantal_pixels; 00035 } 00036 00037 public void add(float getal){ 00038 add_L_1(getal); 00039 add_L_2(getal); 00040 add_Infty(getal); 00041 } 00042 00043 00044 00045 00046 00047 00048 00049 00059 private void add_L_1(float getal){ 00060 this.l_1+=Math.abs(getal); 00061 } 00062 00063 private float getL_1Norm(){ 00064 return (float) Math.sqrt(this.l_2); 00065 } 00066 00067 private void add_L_2(float getal){ 00068 this.l_2+=Math.pow(getal,2); 00069 } 00070 00071 private float getL_2Norm(){ 00072 return (float) Math.sqrt(this.l_2); 00073 } 00074 00075 00076 private void add_Infty(float getal){ 00077 this.infty=Math.max(infty,Math.abs(getal)); 00078 } 00079 00080 private float getInftyNorm(){ 00081 return this.infty;} 00082 00089 public void addSobelev(float getal){ 00090 this.sobolev+=Math.pow(getal,2); 00091 } 00092 00093 private float getSobolev(){ 00094 float lambda=1; //0.5f; 00095 float WEIGHTED_SOBOLEV=getL_2Norm() 00096 +lambda*(float)Math.sqrt(sobolev); // @TODO wat is de juiste waarde voor lambda? 00097 return WEIGHTED_SOBOLEV; 00098 } 00099 00100 public float getNorm(int WHICHTORETURN){ 00101 00102 00103 switch (WHICHTORETURN) { 00104 case WEIGHTED_L_2: return getL_2Norm()/(float)aantal_pixels; 00105 case L_1: return getL_1Norm(); 00106 case L_2: return getL_2Norm(); 00107 case INFTY: return getInftyNorm(); 00108 case SOBOLEV: return getSobolev(); 00109 default: Debug.print("couldn't find the number of the norm"); 00110 System.exit(-1); 00111 return -1; 00112 } 00113 00114 } 00115 00116 public static String getNameForNorm(int NORM){ 00117 switch (NORM) { 00118 case L_1: return "L_1"; 00119 00120 case L_2: return "L_2"; 00121 00122 case INFTY: return "Infinity"; 00123 00124 case WEIGHTED_L_2: return "WEIGHTED_L_2"; 00125 00126 case SOBOLEV: return "SOBOLEV"; 00127 default: Debug.print("couldn't find the name of the norm"); 00128 break; 00129 } 00130 return null; 00131 } 00132 00133 00134 }
1.5.5