Tag Archives: algorithms

Graph the gamma function in C#

The post Calculate the gamma function in C# uses numerical integration to calculate the gamma function. (See my book Essential Algorithms, Second Edition for information on numerical integration.) That method works fairly well for calculating Γ(x) where x ≤ 1. … Continue reading

Posted in algorithms, graphics, mathematics | Tagged , , , , , , , , | Comments Off on Graph the gamma function in C#

Calculate the gamma function in C#

The gamma function, represented by the capital Greek letter gamma Γ, was derived by Daniel Bernoulli for complex numbers with a positive real part. The interesting thing about the gamma function is that &Gamma(n + 1) = n! for integers … Continue reading

Posted in algorithms, mathematics | Tagged , , , , , , , | 3 Comments

Simulate a doubling betting strategy in C#

Casinos love customers who have a betting strategy because those customers always end up losing. As long as the game’s events are independent of each other (for example, one roll of the dice does not depend on the previous rolls), … Continue reading

Posted in algorithms, mathematics | Tagged , , , , , , , , , | 1 Comment

Use k-means clustering to find clusters of data in C#

I was recently editing John Mueller and Luca Massaron’s book Machine Learning For Dummies, Second Edition. (This link is for the first edition. I’ll try to remember to update it when the new edition is available.) The book is about … Continue reading

Posted in algorithms | Tagged , , , , , , , , | Comments Off on Use k-means clustering to find clusters of data in C#

Automatically set camera distance in WPF and C#

This example extends the post Build a geodesic sphere with WPF and C# to let you automatically set the camera distance to make the scene fill the viewport. Making a 3D scene fill the viewport nicely can be tricky. The … Continue reading

Posted in 3D graphics, algorithms, graphics, mathematics, wpf | Tagged , , , , , , , , , , , , , , , , | 6 Comments

Enlarge a polygon that has colinear vertices in C#

The example Enlarge a polygon in C# shows how you can expand a polygon. The basic idea is to offset each of the polygon’s edges away from the polygon’s center and then see where adjacent edges intersect as shown in … Continue reading

Posted in algorithms, drawing, graphics, mathematics | Tagged , , , , , , , , , , , , , | 1 Comment

Overlay parts of images in C#

My previous post Brighten pixels in an image in C# lets you brighten certain pixels in an image. Unfortunately is often brightens pixels outside of the area that you want to modify. For example, in the left side of the … Continue reading

Posted in algorithms, graphics, image processing | Tagged , , , , , , , , | Comments Off on Overlay parts of images in C#

Brighten pixels in an image in C#

Sometimes when I take a picture, the poor lighting makes some pixels come out less brightly than I would like. For example, in the picture on the right the red raspberries aren’t very red. This example lets you brighten pixels. … Continue reading

Posted in algorithms, graphics, image processing | Tagged , , , , , , , , | 1 Comment

Perform binary contrast enhancement more quickly in C#

The example Perform binary contrast enhancement interactively in C# lets you convert an image into completely black and white pixels depending on their brightness. Pixels that are brighter than a given cutoff value are converted into white. Those that are … Continue reading

Posted in algorithms, image processing | Tagged , , , , , , , | Comments Off on Perform binary contrast enhancement more quickly in C#

Make a blended composite image in C#

The other day I wanted to do something that all of us do from time to time: make a composite image with the Eye of Sauron on top of another picture. This turned out to be a bit more complicated … Continue reading

Posted in algorithms, graphics, image processing | Tagged , , , , , , , , , , , | Comments Off on Make a blended composite image in C#