Пример #1
0
        private void updateMatrixText()
        {
            ConvolutionFilterBase filter1 = (ConvolutionFilterBase)convolutionFilter.SelectedItem;

            numMatrix11.Value     = Convert.ToDecimal(filter1.FilterMatrix[0, 0]);
            numMatrix12.Value     = Convert.ToDecimal(filter1.FilterMatrix[0, 1]);
            numMatrix13.Value     = Convert.ToDecimal(filter1.FilterMatrix[0, 2]);
            numMatrix21.Value     = Convert.ToDecimal(filter1.FilterMatrix[1, 0]);
            numMatrix22.Value     = Convert.ToDecimal(filter1.FilterMatrix[1, 1]);
            numMatrix23.Value     = Convert.ToDecimal(filter1.FilterMatrix[1, 2]);
            numMatrix31.Value     = Convert.ToDecimal(filter1.FilterMatrix[2, 0]);
            numMatrix32.Value     = Convert.ToDecimal(filter1.FilterMatrix[2, 1]);
            numMatrix33.Value     = Convert.ToDecimal(filter1.FilterMatrix[2, 2]);
            numMatrixOffset.Value = Convert.ToDecimal(filter1.Bias);
            numMatrixGain.Value   = Convert.ToDecimal(filter1.Factor) * 32768;

            lbFilter11.Text          = filter1.FilterMatrix[0, 0].ToString();
            lbFilter12.Text          = filter1.FilterMatrix[0, 1].ToString();
            lbFilter13.Text          = filter1.FilterMatrix[0, 2].ToString();
            lbFilter21.Text          = filter1.FilterMatrix[1, 0].ToString();
            lbFilter22.Text          = filter1.FilterMatrix[1, 1].ToString();
            lbFilter23.Text          = filter1.FilterMatrix[1, 2].ToString();
            lbFilter31.Text          = filter1.FilterMatrix[2, 0].ToString();
            lbFilter32.Text          = filter1.FilterMatrix[2, 1].ToString();
            lbFilter33.Text          = filter1.FilterMatrix[2, 2].ToString();
            lbOffsetandPlus.Text     = "X Image + " + filter1.Bias.ToString();
            lbGainAndMultiplier.Text = String.Format("{0:0.00}", filter1.Factor) + " X ";
        }
Пример #2
0
        private void applyFilter_Click(object sender, EventArgs e)
        {
            if (cbEnableGray.Checked | (convolutionFilter.SelectedItem is SobelFilter))
            {
                previewBitmap = grayscale(originalBitmap);
            }
            else
            {
                previewBitmap = originalBitmap;
            }

            ConvolutionFilterBase filter = null;

            if (convolutionFilter.SelectedItem is ConvolutionFilterBase)
            {
                filter = (ConvolutionFilterBase)convolutionFilter.SelectedItem;
            }

            if (convolutionFilter.SelectedItem is SobelFilter)
            {
                resultBitmap = previewBitmap.SobelFilter(filter);
            }
            else
            {
                resultBitmap = previewBitmap.ConvolutionFilter(filter);
            }

            pictureBox1.Image = resultBitmap;

            saveImage.Enabled = true;
        }
Пример #3
0
        private void matrix_Changed(object sender, EventArgs e)
        {
            if (enableEntries())
            {
                ConvolutionFilterBase filter = (ConvolutionFilterBase)convolutionFilter.SelectedItem;

                filter.Bias               = Convert.ToDouble(numMatrixOffset.Value);
                filter.Factor             = Convert.ToDouble(numMatrixGain.Value) / 32768;
                filter.FilterMatrix[0, 0] = Convert.ToDouble(numMatrix11.Value);
                filter.FilterMatrix[0, 1] = Convert.ToDouble(numMatrix12.Value);
                filter.FilterMatrix[0, 2] = Convert.ToDouble(numMatrix13.Value);
                filter.FilterMatrix[1, 0] = Convert.ToDouble(numMatrix21.Value);
                filter.FilterMatrix[1, 1] = Convert.ToDouble(numMatrix22.Value);
                filter.FilterMatrix[1, 2] = Convert.ToDouble(numMatrix23.Value);
                filter.FilterMatrix[2, 0] = Convert.ToDouble(numMatrix31.Value);
                filter.FilterMatrix[2, 1] = Convert.ToDouble(numMatrix32.Value);
                filter.FilterMatrix[2, 2] = Convert.ToDouble(numMatrix33.Value);
            }
            updateMatrixText();
        }