Texturer filter.

Adjust pixels’ color values using factors from the given texture. In conjunction with different type of texture generators, the filter may produce different type of interesting effects.

The filter uses specified texture to adjust values using the next formula:
dst = src * PreserveLevel + src * FilterLevel * textureValue,
where src is value of pixel in a source image, dst is value of pixel in a destination image and textureValue is corresponding value from provided texture (see TextureGenerator or Texture). Using PreserveLevel and FilterLevel values it is possible to control the portion of source data affected by texture.

In most cases the PreserveLevel and FilterLevel properties are set in such way, that PreserveLevel + FilterLevel = 1. But there is no limitations actually for those values, so their sum may be as greater, as lower than 1 in order create different type of effects.

The filter accepts 8 bpp grayscale and 24 bpp color images for processing.

Sample usage:

// create filter Texturer filter = new Texturer( new TextileTexture( ), 0.3, 0.7 ); // apply the filter filter.ApplyInPlace( image );

Initial image:

Result image:

상속: BaseInPlacePartialFilter
예제 #1
0
 private void btnEffectApply_Click(object sender, EventArgs e)
 {
     resizerControl.Visible = true;
     IFilter imgeFilter = default(IFilter);
     Button effect = (Button)sender;
     Bitmap imgEffect = img;
     if (effect.Name == "btnGray")
     {
         imgeFilter = new GrayscaleBT709();
     }
     else if (effect.Name == "btnSeperia")
     {
         imgeFilter = new Sepia();
     }
     else if (effect.Name == "btnInvert")
     {
         imgeFilter = new Invert();
     }
     else if (effect.Name == "btnCommon")
     {
         imgeFilter = new BurkesDithering();
     }
     else if (effect.Name == "btnBlur")
     {
         imgeFilter = new Blur();
     }
     else if (effect.Name == "btnJitter")
     {
         imgeFilter = new Texturer(new AForge.Imaging.Textures.MarbleTexture(10, 11), 0.7f, 0.3f);
     }
     else if (effect.Name == "btnCyan")
     {
         imgeFilter = new ChannelFiltering(new IntRange(0, 0), new IntRange(0, 255), new IntRange(0, 255));
     }
     else if (effect.Name == "btnBlackWhite")
     {
         imgeFilter = new YCbCrExtractChannel(AForge.Imaging.YCbCr.CrIndex);
     }
     imgEffect = imgeFilter.Apply(img);
     panelImage.BackgroundImage = imgEffect;
     //img = imgEffect;
 }
예제 #2
0
 private void Effect()
 {
     IFilter imgeFilter = new BurkesDithering();
     Bitmap bitimg = new Bitmap(imgeFilter.Apply(img), 90, 111);
     btnCommon.Image = bitimg;
     imgeFilter = new GrayscaleBT709();
     btnGray.Image = new Bitmap(imgeFilter.Apply(img), 90, 111);
     imgeFilter = new Sepia();
     bitimg = new Bitmap(imgeFilter.Apply(img), 90, 111);
     btnSeperia.Image = bitimg;
     imgeFilter = new Invert();
     bitimg = new Bitmap(imgeFilter.Apply(img), 90, 111);
     btnInvert.Image = bitimg;
     imgeFilter = new Blur();
     bitimg = new Bitmap(imgeFilter.Apply(img), 90, 111);
     btnBlur.Image = bitimg;
     imgeFilter = new Texturer(new AForge.Imaging.Textures.MarbleTexture(10, 11), 0.7f, 0.3f);
     bitimg = new Bitmap(imgeFilter.Apply(img), 90, 111);
     btnJitter.Image = bitimg;
     imgeFilter = new ChannelFiltering(new IntRange(0, 0), new IntRange(0, 255), new IntRange(0, 255));
     bitimg = new Bitmap(imgeFilter.Apply(img), 90, 111);
     btnCyan.Image = bitimg;
     imgeFilter = new YCbCrExtractChannel(AForge.Imaging.YCbCr.CrIndex);
     bitimg = new Bitmap(imgeFilter.Apply(img), 90, 111);
     btnBlackWhite.Image = bitimg;
 }