public Bitmap ToImage(bool Freq = false) { int scale = _Width * _Height; int i; double max = double.MinValue; double min = double.MaxValue; double[] tmpdata = new double[scale]; for (i = 0; i < scale; ++i) { tmpdata[i] = this[i].Modulus; if (Freq) { tmpdata[i] = Math.Log10(tmpdata[i]); } max = max < tmpdata[i] ? tmpdata[i] : max; min = min > tmpdata[i] ? tmpdata[i] : min; } double s = 255 / (max - min); Bitmap result = new Bitmap(_Width, _Height); BitmapData resultdata = result.LockBits(new Rectangle(0, 0, result.Width, result.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb); byte * resultpointer = (byte *)resultdata.Scan0.ToPointer(); for (i = 0; i < scale; ++i) { resultpointer[0] = resultpointer[1] = resultpointer[2] = ImgF.D2B((tmpdata[i] - min) * s); resultpointer[3] = 255; resultpointer += 4; } result.UnlockBits(resultdata); return(result); }
public BGRImg Extend() { int ewidth = (int)Math.Pow(2, ImgF.Log2(_Width)), eheight = (int)Math.Pow(2, ImgF.Log2(_Height)); BGRImg result = new BGRImg(ewidth, eheight); int startx = (ewidth - _Width) / 2, starty = (eheight - _Height) / 2; int endx = startx + _Width, endy = starty + _Height; int ttx, tty; int y, x, t; for (y = 0; y < eheight; ++y) { for (x = 0; x < ewidth; ++x) { ttx = x; tty = y; while (ttx - startx < 0) { ttx += Math.Abs(ttx - startx) * 2 - 1; } while (ttx - startx >= _Width) { ttx -= Math.Abs(ttx - startx - _Width) * 2 + 1; } while (tty - starty < 0) { tty += Math.Abs(tty - starty) * 2 - 1; } while (tty - starty >= _Height) { tty -= Math.Abs(tty - starty - _Height) * 2 + 1; } for (t = 0; t < 3; ++t) { result[t, x, y] = Complex.FromRealImaginary(this[t, ttx - startx, tty - starty].Real, this[t, ttx - startx, tty - starty].Imag); } } } return(result); }
public void Sharpen() { ImgF.Sharpen(_BGR[0], _Width, _Height); ImgF.Sharpen(_BGR[1], _Width, _Height); ImgF.Sharpen(_BGR[2], _Width, _Height); }
private void SpatialFilter(double[,] filter) { _BGR[0] = ImgF.SpatialFilter(_BGR[0], _Width, _Height, filter); _BGR[1] = ImgF.SpatialFilter(_BGR[1], _Width, _Height, filter); _BGR[2] = ImgF.SpatialFilter(_BGR[2], _Width, _Height, filter); }