// Use this for initialization void Start() { srcBmp = new BitmapData(); srcBmp.SetTexture2D(texture); srcBmp.Unlock(); distBmp = new BitmapData(srcBmp.width, srcBmp.height, Color.black); // Debug.Log(FlashInt.BitmapData.UintToColor(0xffff0000)); // Debug.Log((Color32)Color.red); // // Debug.Log(FlashInt.BitmapData.ColorToUint(Color.red)); // Debug.Log(0xffff0000); // edge int[] matrix = new int[] { -1, -1, -1, -1, 8, -1, -1, -1, -1 }; // フィルタカーネル int divisor = 1; int bias = 0; /* * // 'blur': * int[] matrix = new int[]{ 1, 1, 1, * 1, 1, 1, * 1, 1, 1}; * int divisor = 9; * int bias = 0; * * /* * //'sharpness': * int[] matrix = new int[]{-1, -1, -1, * -1, 9, -1, * -1, -1, -1}; * int divisor = 1; * int bias = 0; */ /* * // emboss * int[] matrix = new int[]{-2, -1, 0, * -1, 1, 1, * 0, 1, 2}; * int divisor = 1; * int bias = 0; */ convolutionFilter = new ConvolutionFilter(matrix, divisor, bias); grayScaleFilter = new MatrixFilter(new float[] { 0.298912f, 0.586611f, 0.114478f, 0, 0, 0.298912f, 0.586611f, 0.114478f, 0, 0, 0.298912f, 0.586611f, 0.114478f, 0, 0, 0, 0, 0, 1, 0 }); filter = new ColorMatrixFilter(new float[] { -1, 0, 0, 0, 1, 0, -1, 0, 0, 1, 0, 0, -1, 0, 1, 0, 0, 0, 1, 0 }); }
private void Start() { sharpness = FindObjectOfType <MatrixFilter>(); linearCorrection = FindObjectOfType <LinearCorrection>(); blackWhite = FindObjectOfType <BlackWhite>(); medianFilter = FindObjectOfType <MedianFilter>(); }
public Laplacian3x3Gaussian3x3Filter(string key, int factor) : base(key, null) { _gaussian3x3Filter = (Gaussian3x3Filter)MatrixFilter.CreateMatrixFilter("Gaussian3x3Filter"); _gaussian3x3Filter.GrayScale = true; _gaussian3x3Filter.Factor = factor; _laplacian3x3Filter = (Laplacian3x3Filter)MatrixFilter.CreateMatrixFilter("Laplacian3x3Filter"); }
public void CalculateMatrixParameters_CalculatesOffsetCorrect1() { var matrix = MatrixPopulator.CreateIncrementedInt(100, 200); MatrixFilter.CalculateMatrixParameters(matrix, 31, 21, 1, 1, out var rowOffset, out var colOffset, out _, out _); Assert.AreEqual(15, rowOffset); Assert.AreEqual(10, colOffset); }
public void CalculateMatrixParameters_CalculatesRemainingCorrect1() { var matrix = MatrixPopulator.CreateIncrementedInt(100, 200); MatrixFilter.CalculateMatrixParameters(matrix, 3, 11, 1, 1, out _, out _, out var remainingRows, out var remainingColumns); Assert.AreEqual(98, remainingRows); Assert.AreEqual(190, remainingColumns); }
/// <summary> /// Filter /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FilterCustomMenu_Click(object sender, RoutedEventArgs e) { CustomFilterWindow windows = new CustomFilterWindow(); windows.ShowDialog(); if (windows.isSelectFilter == true && windows.choseTable != null) { IImageFilter matrixFilter = new MatrixFilter(windows.filterName, windows.choseTable); this.UseFilter(matrixFilter); } }
private void cbEdgeDetectionFilter_SelectedIndexChanged(object sender, EventArgs e) { ToolStripComboBox combobox = (ToolStripComboBox)sender; if (combobox.SelectedIndex == -1) { return; } string edgefilter = combobox.SelectedItem.ToString(); //Type t = Type.GetType("GoodPictureLibrary.Filters." + edgefilter); // Filter filter = MatrixFilter.CreateMatrixFilter<Gaussian3x3Filter>(); Filter filter = MatrixFilter.CreateMatrixFilter(edgefilter); ProcessUsingFilter(filter, true); }
public void ApplyFilter(BitmapData src, Rectangle rect, Point pt, MatrixFilter ff) { byte[] srcData = src._data; float[] f = ff.filter; int w = this.width; for (int y = rect.y; y < rect.y + rect.height; y++) { for (int x = rect.x; x < rect.x + rect.width; x++) { // old int r = (int)srcData[x * 4 + y * w * 4], g = (int)srcData[x * 4 + y * w * 4 + 1], b = (int)srcData[x * 4 + y * w * 4 + 2], a = (int)srcData[x * 4 + y * w * 4 + 3]; this._data[x * 4 + y * w * 4] = (byte)(r * f[0] + g * f[1] + b * f[2] + a * f[3] + f[4]); //Rnew this._data[x * 4 + y * w * 4 + 1] = (byte)(r * f[5] + g * f[6] + b * f[7] + a * f[8] + f[9]); //Gnew this._data[x * 4 + y * w * 4 + 2] = (byte)(r * f[10] + g * f[11] + b * f[12] + a * f[13] + f[14]); //Bnew this._data[x * 4 + y * w * 4 + 3] = (byte)(r * f[15] + g * f[16] + b * f[17] + a * f[18] + f[19]); //Anew } } }
public Kirsch3x3Filter(string key, float[,] expression, int factor = 1, bool grayScale = true) : base(key, expression, factor, grayScale) { kirsch3x3Horizontal = CreateMatrixFilter("Kirsch3x3HorizontalFilter"); kirsch3x3Vertical = CreateMatrixFilter("Kirsch3x3VerticalFilter"); }
public void ApplyFilter(Rectangle rect, Point pt, MatrixFilter ff) { ApplyFilter(this, rect, pt, ff); }
// http://livedocs.adobe.com/flash/9.0_jp/ActionScriptLangRefV3/flash/filters/ColorMatrixFilter.html#ColorMatrixFilter() public void ApplyFilter(MatrixFilter ff) { ApplyFilter(this, new Rectangle(0, 0, this.width, this.height), null, ff); }
public void CalculateMatrixParameters_StrideNotDivisibleByRemainingColumnsRows_ThrowsError(int yStride, int xStride) { var matrix = MatrixPopulator.CreateIncrementedInt(300, 600); Assert.Throws <StrideException>(() => MatrixFilter.CalculateMatrixParameters(matrix, 11, 11, yStride, xStride, out _, out _, out _, out _)); }
public void CalculateMatrixParameters_StrideBiggerThanRowsColumns_ThrowsError(int yStride, int xStride) { var matrix = MatrixPopulator.CreateIncrementedInt(4, 6, 0); Assert.Throws <StrideException>(() => MatrixFilter.CalculateMatrixParameters(matrix, 3, 3, yStride, xStride, out _, out _, out _, out _)); }
public void CalculateMatrixParameters_InvalidStride_ThrowsError(int yStride, int xStride) { var matrix = MatrixPopulator.CreateIncrementedInt(4, 6, 0); Assert.Throws <OutOfRangeException>(() => MatrixFilter.CalculateMatrixParameters(matrix, 3, 3, yStride, xStride, out _, out _, out _, out _)); }
public void CalculateMatrixParameters_Invalid_RowsColumns_ThrowsError(int rows, int columns) { var matrix = MatrixPopulator.CreateIncrementedInt(4, 4); Assert.Throws <OutOfRangeException>(() => MatrixFilter.CalculateMatrixParameters(matrix, rows, columns, 1, 1, out _, out _, out _, out _)); }
public void CalculateMatrixParameters_EvenColumns_ThrowsError(int rows, int columns) { var matrix = MatrixPopulator.CreateRandomInt(10, 10); Assert.Throws <EvenException>(() => MatrixFilter.CalculateMatrixParameters(matrix, rows, columns, 1, 1, out _, out _, out _, out _)); }