AForge.Imaging.Filters.FiltersSequence.Apply C# (CSharp) Метод

Apply() публичный Метод

Apply filter to an image in unmanaged memory.

The method keeps the source image unchanged and puts result of image processing into destination image.

The destination image must have width, height and pixel format as it is expected by the final filter in the sequence.

No filters were added into the filters' sequence.
public Apply ( UnmanagedImage sourceImage, UnmanagedImage destinationImage ) : void
sourceImage UnmanagedImage Source image in unmanaged memory to apply filter to.
destinationImage UnmanagedImage Destination image in unmanaged memory to put result into.
Результат void
        public void Apply( UnmanagedImage sourceImage, UnmanagedImage destinationImage )
        {
            int n = InnerList.Count;

            // check for empty sequence
            if ( n == 0 )
                throw new ApplicationException( "No filters in the sequence." );

            if ( n == 1 )
            {
                ( (IFilter) InnerList[0] ).Apply( sourceImage, destinationImage );
            }
            else
            {
                UnmanagedImage tmpImg1 = null;
                UnmanagedImage tmpImg2 = null;

                // apply the first filter
                tmpImg1 = ( (IFilter) InnerList[0] ).Apply( sourceImage );

                // apply other filters, except the last one
                n--;
                for ( int i = 1; i < n; i++ )
                {
                    tmpImg2 = tmpImg1;
                    tmpImg1 = ( (IFilter) InnerList[i] ).Apply( tmpImg2 );
                    tmpImg2.Dispose( );
                }

                ( (IFilter) InnerList[n] ).Apply( tmpImg1, destinationImage );
            }
        }
	}

Same methods

FiltersSequence::Apply ( Bitmap image ) : Bitmap
FiltersSequence::Apply ( BitmapData imageData ) : Bitmap
FiltersSequence::Apply ( UnmanagedImage image ) : UnmanagedImage

Usage Example

Пример #1
1
 private string reconhecerCaptcha(Image img)
 {
     Bitmap imagem = new Bitmap(img);
     imagem = imagem.Clone(new Rectangle(0, 0, img.Width, img.Height), System.Drawing.Imaging.PixelFormat.Format24bppRgb);
     Erosion erosion = new Erosion();
     Dilatation dilatation = new Dilatation();
     Invert inverter = new Invert();
     ColorFiltering cor = new ColorFiltering();
     cor.Blue = new AForge.IntRange(200, 255);
     cor.Red = new AForge.IntRange(200, 255);
     cor.Green = new AForge.IntRange(200, 255);
     Opening open = new Opening();
     BlobsFiltering bc = new BlobsFiltering();
     Closing close = new Closing();
     GaussianSharpen gs = new GaussianSharpen();
     ContrastCorrection cc = new ContrastCorrection();
     bc.MinHeight = 10;
     FiltersSequence seq = new FiltersSequence(gs, inverter, open, inverter, bc, inverter, open, cc, cor, bc, inverter);
     pictureBox.Image = seq.Apply(imagem);
     string reconhecido = OCR((Bitmap)pictureBox.Image);
     return reconhecido;
 }
All Usage Examples Of AForge.Imaging.Filters.FiltersSequence::Apply