Example Image Blur

From BoofCV
Revision as of 19:22, 7 December 2016 by Peter (talk | contribs) (Created page with "<center> <gallery caption="Non-maximum suppression with different settings" heights=250 widths=250 perrow=4 > file:Original_lena512.jpg|Input image file:Example_lena_gaussian_...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Applying different types of image blur is a common way to "remove" noise from images and make later steps more effective. This example shows you how to apply different image blur operators using different interfaces.

Example Code:


  • Image Processing
  • Pre-processing

Related Examples:

Example Code

 * This example shows you can can apply different standard image blur filters to an input image using different
 * interface.  For repeat calls using the filter interface has some advantages, but the procedural can be
 * simple to code up.
 * @author Peter Abeles
public class ExampleImageBlur {

	public static void main(String[] args) {
		ListDisplayPanel panel = new ListDisplayPanel();
		BufferedImage image = UtilImageIO.loadImage(UtilIO.pathExample("standard/lena512.jpg"));


		GrayU8 gray = ConvertBufferedImage.convertFromSingle(image, null, GrayU8.class);
		GrayU8 blurred = gray.createSameShape();

		// size of the blur kernel. square region with a width of radius*2 + 1
		int radius = 8;

		// Apply gaussian blur using a procedural interface
		panel.addImage(ConvertBufferedImage.convertTo(blurred, null, true),"Gaussian");

		// Apply a mean filter using an object oriented interface.  This has the advantage of automatically
		// recycling memory used in intermediate steps
		BlurFilter<GrayU8> filterMean = FactoryBlurFilter.mean(GrayU8.class,radius);
		filterMean.process(gray, blurred);
		panel.addImage(ConvertBufferedImage.convertTo(blurred, null, true),"Mean");

		// Apply a median filter using image type specific procedural interface.  Won't work if the type
		// isn't known at compile time
		panel.addImage(ConvertBufferedImage.convertTo(blurred, null, true),"Median");

		ShowImages.showWindow(panel,"Image Blur Examples",true);