baidu_28600537 2015-05-31 04:22
浏览 568

影像處理C#程式碼相關問題請大大幫忙修正哪裡錯誤

公式如圖片程式碼如下:
我已經先把
pictureBox2.Image是IL ==>也是放大後影像
pictureBox3.Image是Iold ==>濾波後的影像

height = this.pictureBox2.Image.Height;
width = this.pictureBox2.Image.Width;
Bitmap bitmap1 = new Bitmap(pictureBox2.Image);
Bitmap bitmap2 = new Bitmap(pictureBox3.Image);
Bitmap bitmap = new Bitmap(width, height);
double[,] image = new double[width, height];
double[,] image0 = new double[width, height];
double[,] image1 = new double[width, height];
double[, ,] image2 = new double[width, height, 30];
double[, ,] image3 = new double[width, height, 30];
double[,] image4 = new double[width, height];
double[, ,] image5 = new double[width, height, 30];
double[, ,] image6 = new double[width, height, 30];

double[,] image1R = new double[width, height];
double[,] image1G = new double[width, height];
double[,] image1B = new double[width, height];

double[,] image2R = new double[width, height];
double[,] image2G = new double[width, height];
double[,] image2B = new double[width, height];

double[,] image3R = new double[width, height];
double[,] image3G = new double[width, height];
double[,] image3B = new double[width, height];

double[,] image4R = new double[width, height];
double[,] image4G = new double[width, height];
double[,] image4B = new double[width, height];

double[, ,] image5R = new double[width, height,30];
double[, ,] image5G = new double[width, height, 30];
double[, ,] image5B = new double[width, height,30];

double[, ,] image6R = new double[width, height,30];
double[, ,] image6G = new double[width, height, 30];
double[, ,] image6B = new double[width, height,30];

double sum = 0;
double sumb = 0;
double dev = 0;
double devb = 0;
double sum0 = 0;
double sum2 = 0;
double dev0 = 0;
double dev1 = 0;
double gray1 = 0;
double graytest0 = 0;
int v = width * height;
//double B = Convert.ToDouble(textBox1.Text);
double C = Convert.ToDouble(textBox2.Text);
for (x = 0; x < width; x++)
{
for (y = 0; y < height; y++)
{
Color c = bitmap1.GetPixel(x, y);
Color c1 = bitmap2.GetPixel(x, y);
image1R[x, y] = c.R;
image1G[x, y] = c.G;
image1B[x, y] = c.B;

image2R[x, y] = c1.R;
image2G[x, y] = c1.G;
image2B[x, y] = c1.B;

image4R[x, y] = c.R;
image4G[x, y] = c.G;
image4B[x, y] = c.B;
}
}
for (int L = 0; L < C; L++)
{
for (x = 0; x < width; x++)
{
for (y = 0; y < height; y++)
{
image3R[x, y] = 0.01 * ((int)(image1R[x, y] - image2R[x, y]));
image3G[x, y] = 0.01 * ((int)(image1G[x, y] - image2G[x, y]));
image3B[x, y] = 0.01 * ((int)(image1B[x, y] - image2B[x, y]));
image4R[x, y] += image3R[x, y];
image4G[x, y] += image3G[x, y];
image4B[x, y] += image3B[x, y];

image0[x, y] = (image1R[x, y] * 0.299 + image1G[x, y] * 0.587 + image1B[x, y] * 0.114);
image4[x, y] = (image4R[x, y] * 0.299 + image4G[x, y] * 0.587 + image4B[x, y] * 0.114);
image2[x, y, L] = image4[x, y];
image5[x, y, L] = image0[x, y];
image5R[x, y, L] = image4[x, y];
image6R[x, y, L] = image4[x, y];
}
}
for (x = 0; x < width; x++)
{
for (y = 0; y < height; y++)
{
image4[x, y] = 0;
}
}
for (x = 0; x < width; x++)
{
for (y = 0; y < height; y++)
{
sum0 += image5R[x, y, L];
}
}
sum2 = sum0 / v;
for (x = 0; x < width; x++)
{
for (y = 0; y < height; y++)
{
dev0 += Math.Pow((image6R[x, y, L]-sum2 ), 2);
}
}
dev1 = Math.Sqrt(dev0 / v)*0.2;//絕對值
for (x = 0; x < width; x++)
{
for (y = 0; y < height; y++)
{
image6[x, y, L] = image5[x, y, L];
image3[x, y, L] = image2[x, y, L];
gray1 += image3[x, y, L]/v;
graytest0 += image6[x, y, L]/v ;
}
}
for (x = 0; x < width; x++)
{
for (y = 0; y < height; y++)
{
Color c = bitmap1.GetPixel(x, y);
image1R[x, y] = c.R;
image1G[x, y] = c.G;
image1B[x, y] = c.B;
image[x, y] = (image1R[x, y] * 0.299 + image1G[x, y] * 0.587 + image1B[x, y] * 0.114);
}
}
for (x = 0; x < width; x++)
{
for (y = 0; y < height; y++)
{
sum += image[x, y];
}
}
sumb = sum / v;
for (x = 0; x < width; x++)
{
for (y = 0; y < height; y++)
{
dev += Math.Pow((image[x, y] -sumb ), 2);
}
}
devb = Math.Sqrt(dev / v)*0.2;图片说明

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 c程序不知道为什么得不到结果
    • ¥40 复杂的限制性的商函数处理
    • ¥15 程序不包含适用于入口点的静态Main方法
    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置