|
// Accord Imaging Library
// Accord.NET framework
// http://www.crsouza.com
//
// Copyright © César Souza, 2009-2010
// cesarsouza at gmail.com
//
namespace Accord.Imaging.Filters
{
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using AForge.Imaging.Filters;
using AForge;
using AForge.Imaging;
/// <summary>
/// Filter to mark (highlight) pairs of points in a image.
/// </summary>
///
public class PairsMarker : BaseInPlaceFilter
{
private Color markerColor = Color.White;
private IntPoint[] points1;
private IntPoint[] points2;
private Dictionary<PixelFormat, PixelFormat> formatTranslations = new Dictionary<PixelFormat, PixelFormat>();
/// <summary>
/// Color used to mark pairs.
/// </summary>
public Color MarkerColor
{
get { return markerColor; }
set { markerColor = value; }
}
/// <summary>
/// The first set of points.
/// </summary>
public IntPoint[] Points1
{
get { return points1; }
set { points1 = value; }
}
/// <summary>
/// The corresponding points to the first set of points.
/// </summary>
public IntPoint[] Points2
{
get { return points2; }
set { points2 = value; }
}
/// <summary>
/// Format translations dictionary.
/// </summary>
public override Dictionary<PixelFormat, PixelFormat> FormatTranslations
{
get { return formatTranslations; }
}
/// <summary>
/// Initializes a new instance of the <see cref="PairsMarker"/> class.
/// </summary>
///
/// <param name="points1">Set of starting points.</param>
/// <param name="points2">Set of corresponding points.</param>
///
public PairsMarker(IntPoint[] points1, IntPoint[] points2)
: this(points1, points2, Color.White)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="PairsMarker"/> class.
/// </summary>
///
/// <param name="points1">Set of starting points.</param>
/// <param name="points2">Set of corresponding points.</param>
/// <param name="markerColor">The color of the lines to be marked.</param>
///
public PairsMarker(IntPoint[] points1, IntPoint[] points2, Color markerColor)
{
this.points1 = points1;
this.points2 = points2;
this.markerColor = markerColor;
formatTranslations[PixelFormat.Format8bppIndexed] = PixelFormat.Format8bppIndexed;
formatTranslations[PixelFormat.Format24bppRgb] = PixelFormat.Format24bppRgb;
}
/// <summary>
/// Process the filter on the specified image.
/// </summary>
///
/// <param name="image">Source image data.</param>
///
protected override void ProcessFilter(UnmanagedImage image)
{
// mark all lines
for (int i = 0; i < points1.Length; i++)
{
Drawing.Line(image, points1[i], points2[i], markerColor);
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Computer and technology enthusiast, interested in artificial intelligence and image processing. Has a Master's degree on Computer Science specialized on Image and Signal Processing, with expertise on Machine Learning, Computer Vision, Pattern Recognition and Data Mining systems. Author of the
Accord.NET Framework for developing scientific computing applications.
If you would like to hire good developers to build your dream application, please check out
DaitanGroup, one of the top outsourcing companies in Brazil. This company, located in Brazil's Sillicon Valley but with US-based offices, has huge experience developing telecommunications software for large and small companies worldwide.