FxMedian Method (GdPictureImaging)
In This Topic
Performs a median filter of any size of kernel (amount of pixels included in operation) on a
GdPicture image or on an area of a GdPicture image defined by SetROI() method.
This method clears the image of Salt and Pepper noise, which is random dot like noise of white and black color.
Syntax
Parameters
- ImageID
- GdPicture image identifier.
- KernelSize
- Level corresponding to number of pixels to include in the median operation,
where Level = n, corresponds to (n*2+1)^2 pixels to be included. For
Example, KernelSize = 1 includes 9 pixels in the median operation,
KernelSize = 2 includes 25 pixels in the median operation. Range from 1 to 60.
If value supplied is out of range the method will return GdPictureStatus.InvalidParameter.
Return Value
A member of the GdPictureStatus enumeration.
Example
Performing a median filter on a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Range from 1 to 60. The higher the value, the harsher it applies the filter.
int kernel_size = 2;
// Performing a median filter.
gdpictureImaging.FxMedian(imageID, kernel_size);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Example
Performing a median filter on a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Range from 1 to 60. The higher the value, the harsher it applies the filter.
int kernel_size = 2;
// Performing a median filter.
gdpictureImaging.FxMedian(imageID, kernel_size);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
See Also