我们直接上代码,这更能说明问题:
int[] oct1dog1layer512 = new int[512 * 512];
int[] oct1dog2layer512 = new int[512 * 512];
int[] oct1dog3layer512 = new int[512 * 512];
int[] oct1dog4layer512 = new int[512 * 512];
int[] oct1dog5layer512 = new int[512 * 512];
private void button21_Click(object sender, EventArgs e)
{
byte[] dog1layer512 = new byte[512 * 512];//第一组第一层dog金子塔
for (int i = 0; i < 512 * 512; i++)
{//
int temp = oct1globbuffer2layer[i] - oct1globbuffer1layer[i];//高斯金字塔2层-1层
// temp =Math.Abs(temp);
oct1dog1layer512[i] = temp;//第一组第一层dog金子塔
temp *= 20;//不如此,一团黑
dog1layer512[i] = temp > 0 ? (byte)temp : (byte)Math.Abs(temp);//用来界面显示的第一组第一层dog金子塔
// dog1layer512[i] = (byte)temp ;
}
int ww = 512;
int hh = 512;
///测试8位显示
Bitmap cutPic88 = new Bitmap(ww, hh, PixelFormat.Format8bppIndexed);
System.Drawing.Imaging.ColorPalette cp = cutPic88.Palette;
for (int i = 0; i < 256; i++)
{
cp.Entries[i] = Color.FromArgb(255, i, i, i);
}
cutPic88.Palette = cp;
BitmapData _cutPic8 = cutPic88.LockBits(new Rectangle(0, 0, ww, hh), ImageLockMode.ReadWrite,
cutPic88.PixelFormat);
IntPtr ptr00 = _cutPic8.Scan0;//得到首地址
//把cutvalues数组给ptr
System.Runtime.InteropServices.Marshal.Copy(dog1layer512, 0, ptr00, ww * hh);
cutPic88.UnlockBits(_cutPic8);
pictureBox6.Image = cutPic88;//pictureBox显示dog金字塔
}