/* private UnsafeBitmap getEnhancedColoredImageR(UnsafeBitmap goal,int color) * { * EVector acc; * EVector temp; * enhanced_IMAGE = new EVector[E_Image.Length][]; * for (int x = 0; x < E_Image.Length; x++) * { * enhanced_IMAGE[x] = new EVector[E_Image[x].Length]; * for (int y = 0; y < E_Image[x].Length; y++) * { * acc = new EVector(0.0d); * for (int i = 0; i < M; i++) * { * for (int j = 0; j < N; j++) * { * temp = (lambdas[i][j] * (E_Image[x][y] + taws[i][j])); * temp = W[i][j][x][y] * temp; * acc = acc + temp; * } * } * enhanced_IMAGE[x][y] = acc; * } * } * //return convertoToImage(enhanced_IMAGE); * return convertoToColoredImage(enhanced_IMAGE, goal, color); * }*/ public UnsafeBitmap getEnhancedImage() { EVector acc; EVector temp; enhanced_IMAGE = new EVector[E_Image.Length][]; for (int x = 0; x < E_Image.Length; x++) { enhanced_IMAGE[x] = new EVector[E_Image[x].Length]; for (int y = 0; y < E_Image[x].Length; y++) { acc = new EVector(0.0d); for (int i = 0; i < M; i++) { for (int j = 0; j < N; j++) { temp = (lambdas[i][j] * (E_Image[x][y] + taws[i][j])); temp = W[i][j][x][y] * temp; acc = acc + temp; } } enhanced_IMAGE[x][y] = acc; } } link.status = "DRAWING the Enhanced Image"; link.val = 20; doDrawing(link); return(convertoToImage(enhanced_IMAGE)); }
public static EVector Mean(EVector[][] F) { EVector acc = new EVector(0.0d); double stat = 1.0d / (F.Length * F[0].Length); for (int x = 0; x < F.Length; x++) { for (int y = 0; y < F[x].Length; y++) { acc = acc + (stat * F[x][y]); } } return(acc); }
private void transformTo_Espace() { E_Image = new EVector[source.Width][]; //source.LockBitmap(); for (int x = 0; x < source.Width; x++) { E_Image[x] = new EVector[source.Height]; for (int y = 0; y < source.Height; y++) { E_Image[x][y] = new EVector((int)source.GetPixel(x, y).red); } } source.UnlockBitmap(); }
public static double Variance(EVector[][] F, EVector mean) { double acc = 0; EVector temp; double temp2; double stat = (F.Length * F[0].Length); for (int x = 0; x < F.Length; x++) { for (int y = 0; y < F[x].Length; y++) { temp = F[x][y] - mean; temp2 = temp.RealValue; temp2 = Math.Pow(temp2, 2); acc += temp2 / stat; } } return(acc); }
private void calculate_Lambdas_Taws() { lambdas = new double[M][]; taws = new EVector[M][]; EVector temp = new EVector(0.0d); for (int i = 0; i < M; i++) { lambdas[i] = new double[N]; taws[i] = new EVector[N]; for (int j = 0; j < N; j++) { lambdas[i][j] = Math.Sqrt(1.0d / 3.0d) / variences[i][j]; taws[i][j] = temp - means[i][j]; } } }
private void transformTo_E_Colored_Space() { E_Colored_Image = new EVector[source.Width][][]; luminosity = new EVector[source.Width][]; //source.LockBitmap(); for (int x = 0; x < source.Width; x++) { E_Colored_Image[x] = new EVector[source.Height][]; luminosity[x] = new EVector[source.Height]; for (int y = 0; y < source.Height; y++) { E_Colored_Image[x][y] = new EVector[3]; E_Colored_Image[x][y][0] = new EVector((int)source.GetPixel(x, y).red); E_Colored_Image[x][y][1] = new EVector((int)source.GetPixel(x, y).green); E_Colored_Image[x][y][2] = new EVector((int)source.GetPixel(x, y).blue); luminosity[x][y] = (1.0d / 3.0d) * (E_Colored_Image[x][y][0] + E_Colored_Image[x][y][1] + E_Colored_Image[x][y][2]); } } source.UnlockBitmap(); }
public UnsafeBitmap getEnhancedColoredImage() { EVector acc1, acc2, acc3; EVector temp; enhanced_C_IMAGE = new EVector[E_Colored_Image.Length][][]; for (int x = 0; x < E_Colored_Image.Length; x++) { enhanced_C_IMAGE[x] = new EVector[E_Colored_Image[x].Length][]; for (int y = 0; y < E_Colored_Image[x].Length; y++) { enhanced_C_IMAGE[x][y] = new EVector[3]; acc1 = new EVector(0.0d); acc2 = new EVector(0.0d); acc3 = new EVector(0.0d); for (int i = 0; i < M; i++) { for (int j = 0; j < N; j++) { temp = (lambdas[i][j] * (E_Colored_Image[x][y][0] + taws[i][j])); temp = W[i][j][x][y] * temp; acc1 = acc1 + temp; //////// temp = (lambdas[i][j] * (E_Colored_Image[x][y][1] + taws[i][j])); temp = W[i][j][x][y] * temp; acc2 = acc2 + temp; //////// temp = (lambdas[i][j] * (E_Colored_Image[x][y][2] + taws[i][j])); temp = W[i][j][x][y] * temp; acc3 = acc3 + temp; } } enhanced_C_IMAGE[x][y][0] = acc1; enhanced_C_IMAGE[x][y][1] = acc2; enhanced_C_IMAGE[x][y][2] = acc3; } } link.status = "DRAWING the Enhanced Image"; link.val = 20; doDrawing(link); return(convertoToColoredImage(enhanced_C_IMAGE)); }
private void calculate_Colored_Means() { EVector temp; means = new EVector[M][]; for (int i = 0; i < M; i++) { means[i] = new EVector[N]; for (int j = 0; j < N; j++) { temp = new EVector(0.0d); for (int x = 0; x < luminosity.Length; x++) { for (int y = 0; y < luminosity[x].Length; y++) { temp = temp + ((W[i][j][x][y] / card[i][j]) * luminosity[x][y]); } } means[i][j] = temp; } } }