Skip to content

Image gradient functions implemented in C#.

License

Notifications You must be signed in to change notification settings

karashiiro/GradientDotNet

Repository files navigation

GradientDotNet

Image gradient functions implemented in C#.

Installation

Install-Package GradientDotNet

Gradient algorithms

  • Central difference
  • Intermediate difference
  • Sobel operator
  • Prewitt operator
  • Roberts cross operator

Usage

var greyPixels = new float[img.Height * img.Width];

// Fill your greyscale image

// Or intermediate difference, or Sobel...
var centDiffX = new float[greyPixels.Length];
var centDiffY = new float[greyPixels.Length];
Gradients.CentralDifference(greyPixels, centDiffX, centDiffY, img.Height, img.Width);

You can also create an implementation of IImage that maps get/set calls to another image library to calls that this library can understand, and use that implementation instead of a direct buffer:

var greyImage = new YourImageInterfaceImplementation(img);

// Or intermediate difference, or Sobel...
var centDiffX = new YourImageInterfaceImplementation(centDiffXImg);
var centDiffY = new YourImageInterfaceImplementation(centDiffYImg);
Gradients.CentralDifference(greyImage, centDiffX, centDiffY);

Alternatively, you can use the X and Y gradient calculation functions directly, as follows:

var centDiffX = new float[greyPixels.Length];
var centDiffY = new float[greyPixels.Length];
CentralDifferenceGradient.CalculateX(greyPixels, centDiffX, img.Height, img.Width);
CentralDifferenceGradient.CalculateY(greyPixels, centDiffY, img.Height, img.Width);

About

Image gradient functions implemented in C#.

Resources

License

Stars

Watchers

Forks

Languages