Obscure parts of a picture for privacy in C#

[obscure]

This example lets you obscure parts of a picture to hide sensitive information such as names, email addresses, phone numbers, and photographs. It provides three obscuring styles: Pixelated (the area is replaced with blocks of color), Fuzzy (the area is smoothed so it appears fuzzy), and Redacted (the area is filled with black).

Press Ctrl+O to open a picture file. Then click and drag to select an area to obscure.

The program’s Tools > Parameters menu displays a parameter dialog where you can change the style of obscuring and the size of the graphical kernel used to perform fuzzing and pixelation. (Larger kernels obscure the result more.)

This example uses several techniques that are described in other examples so I won’t repeat those descriptions here. The following list summarizes some of the more useful techniques and the posts that provide more detail.

See those examples for details.

The new parts of the program work like this:

  1. When you load a picture file, the program saves the image in the variable OriginalImage.
  2. The program copies the original image into the variable VisibleImage and displays it.
  3. When you load a new file or change the obscuring parameters, the program makes a copy of the original image and saves it in variable ObscuredImage. Then:
    1. If the obscuring style is Pixelated or Fuzzy, the program then applies the appropriate obscuring method to the entire image in ObscuredImage. The result is a completely obscured image.
    2. If the obscuring style is Redacted, the program doesn’t need to do anything with ObscuredImage.
  4. When you click and drag to select a rectangle, the program obscures the area you select.
    1. If the obscuring style is Pixelated or Fuzzy, the program copies the selected part of the image from ObscuredImage to CurrentImage.
    2. If the obscuring style is Redacted, the program simply fills the selected rectangle with black in CurrentImage.

That’s about all there is to it. Download the example to see the details.


Download Example   Follow me on Twitter   RSS feed   Donate




About RodStephens

Rod Stephens is a software consultant and author who has written more than 30 books and 250 magazine articles covering C#, Visual Basic, Visual Basic for Applications, Delphi, and Java.

This entry was posted in algorithms, files, GDI+, graphics, image processing, tools and tagged , , , , , , , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *