mirror of https://github.com/SixLabors/ImageSharp
83 changed files with 323 additions and 281 deletions
@ -1,7 +1,7 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
// Copyright (c) Six Labors and contributors.
|
||||
// Licensed under the Apache License, Version 2.0.
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
namespace SixLabors.ImageSharp.Processing |
namespace SixLabors.ImageSharp.Processing.Transforms |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// Enumerated anchor positions to apply to resized images.
|
/// Enumerated anchor positions to apply to resized images.
|
||||
@ -1,12 +1,12 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
// Copyright (c) Six Labors and contributors.
|
||||
// Licensed under the Apache License, Version 2.0.
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
namespace SixLabors.ImageSharp.Processing |
namespace SixLabors.ImageSharp.Processing.Transforms |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// The function implements the bicubic kernel algorithm W(x) as described on
|
/// The function implements the bicubic kernel algorithm W(x) as described on
|
||||
/// <see href="https://en.wikipedia.org/wiki/Bicubic_interpolation#Bicubic_convolution_algorithm">Wikipedia</see>
|
/// <see href="https://en.wikipedia.org/wiki/Bicubic_interpolation#Bicubic_convolution_algorithm">Wikipedia</see>
|
||||
/// A commonly used algorithm within imageprocessing that preserves sharpness better than triangle interpolation.
|
/// A commonly used algorithm within image processing that preserves sharpness better than triangle interpolation.
|
||||
/// </summary>
|
/// </summary>
|
||||
public class BicubicResampler : IResampler |
public class BicubicResampler : IResampler |
||||
{ |
{ |
||||
@ -1,7 +1,7 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
// Copyright (c) Six Labors and contributors.
|
||||
// Licensed under the Apache License, Version 2.0.
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
namespace SixLabors.ImageSharp.Processing |
namespace SixLabors.ImageSharp.Processing.Transforms |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// The function implements the box algorithm. Similar to nearest neighbor when upscaling.
|
/// The function implements the box algorithm. Similar to nearest neighbor when upscaling.
|
||||
@ -1,7 +1,7 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
// Copyright (c) Six Labors and contributors.
|
||||
// Licensed under the Apache License, Version 2.0.
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
namespace SixLabors.ImageSharp.Processing |
namespace SixLabors.ImageSharp.Processing.Transforms |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// The Catmull-Rom filter is a well known standard Cubic Filter often used as a interpolation function.
|
/// The Catmull-Rom filter is a well known standard Cubic Filter often used as a interpolation function.
|
||||
@ -1,26 +0,0 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
|
||||
// Licensed under the Apache License, Version 2.0.
|
|
||||
|
|
||||
using System; |
|
||||
using SixLabors.ImageSharp.PixelFormats; |
|
||||
using SixLabors.ImageSharp.Processing.Processors; |
|
||||
|
|
||||
namespace SixLabors.ImageSharp |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// Extension methods for the <see cref="Image{TPixel}"/> type.
|
|
||||
/// </summary>
|
|
||||
public static partial class ImageExtensions |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// Crops an image to the area of greatest entropy.
|
|
||||
/// </summary>
|
|
||||
/// <typeparam name="TPixel">The pixel format.</typeparam>
|
|
||||
/// <param name="source">The image to crop.</param>
|
|
||||
/// <param name="threshold">The threshold for entropic density.</param>
|
|
||||
/// <returns>The <see cref="Image{TPixel}"/></returns>
|
|
||||
public static IImageProcessingContext<TPixel> EntropyCrop<TPixel>(this IImageProcessingContext<TPixel> source, float threshold = .5f) |
|
||||
where TPixel : struct, IPixel<TPixel> |
|
||||
=> source.ApplyProcessor(new EntropyCropProcessor<TPixel>(threshold)); |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,35 @@ |
|||||
|
// Copyright (c) Six Labors and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
using SixLabors.ImageSharp.PixelFormats; |
||||
|
using SixLabors.ImageSharp.Processing.Transforms.Processors; |
||||
|
|
||||
|
namespace SixLabors.ImageSharp.Processing.Transforms |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Adds extensions that allow the application of entropy cropping operations to the <see cref="Image{TPixel}"/> type.
|
||||
|
/// </summary>
|
||||
|
public static class EntropyCropExtensions |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Crops an image to the area of greatest entropy using a threshold for entropic density of <value>.5F</value>.
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="TPixel">The pixel format.</typeparam>
|
||||
|
/// <param name="source">The image to crop.</param>
|
||||
|
/// <returns>The <see cref="Image{TPixel}"/></returns>
|
||||
|
public static IImageProcessingContext<TPixel> EntropyCrop<TPixel>(this IImageProcessingContext<TPixel> source) |
||||
|
where TPixel : struct, IPixel<TPixel> |
||||
|
=> source.ApplyProcessor(new EntropyCropProcessor<TPixel>()); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Crops an image to the area of greatest entropy.
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="TPixel">The pixel format.</typeparam>
|
||||
|
/// <param name="source">The image to crop.</param>
|
||||
|
/// <param name="threshold">The threshold for entropic density.</param>
|
||||
|
/// <returns>The <see cref="Image{TPixel}"/></returns>
|
||||
|
public static IImageProcessingContext<TPixel> EntropyCrop<TPixel>(this IImageProcessingContext<TPixel> source, float threshold) |
||||
|
where TPixel : struct, IPixel<TPixel> |
||||
|
=> source.ApplyProcessor(new EntropyCropProcessor<TPixel>(threshold)); |
||||
|
} |
||||
|
} |
||||
@ -1,7 +1,7 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
// Copyright (c) Six Labors and contributors.
|
||||
// Licensed under the Apache License, Version 2.0.
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
namespace SixLabors.ImageSharp.Processing |
namespace SixLabors.ImageSharp.Processing.Transforms |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// Provides enumeration over how a image should be flipped.
|
/// Provides enumeration over how a image should be flipped.
|
||||
@ -1,7 +1,7 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
// Copyright (c) Six Labors and contributors.
|
||||
// Licensed under the Apache License, Version 2.0.
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
namespace SixLabors.ImageSharp.Processing |
namespace SixLabors.ImageSharp.Processing.Transforms |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// The Hermite filter is type of smoothed triangular interpolation Filter,
|
/// The Hermite filter is type of smoothed triangular interpolation Filter,
|
||||
@ -1,7 +1,7 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
// Copyright (c) Six Labors and contributors.
|
||||
// Licensed under the Apache License, Version 2.0.
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
namespace SixLabors.ImageSharp.Processing |
namespace SixLabors.ImageSharp.Processing.Transforms |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// Encapsulates an interpolation algorithm for resampling images.
|
/// Encapsulates an interpolation algorithm for resampling images.
|
||||
@ -1,7 +1,7 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
// Copyright (c) Six Labors and contributors.
|
||||
// Licensed under the Apache License, Version 2.0.
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
namespace SixLabors.ImageSharp.Processing |
namespace SixLabors.ImageSharp.Processing.Transforms |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// The function implements the Lanczos kernel algorithm as described on
|
/// The function implements the Lanczos kernel algorithm as described on
|
||||
@ -1,7 +1,7 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
// Copyright (c) Six Labors and contributors.
|
||||
// Licensed under the Apache License, Version 2.0.
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
namespace SixLabors.ImageSharp.Processing |
namespace SixLabors.ImageSharp.Processing.Transforms |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// The function implements the Lanczos kernel algorithm as described on
|
/// The function implements the Lanczos kernel algorithm as described on
|
||||
@ -1,7 +1,7 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
// Copyright (c) Six Labors and contributors.
|
||||
// Licensed under the Apache License, Version 2.0.
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
namespace SixLabors.ImageSharp.Processing |
namespace SixLabors.ImageSharp.Processing.Transforms |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// The function implements the Lanczos kernel algorithm as described on
|
/// The function implements the Lanczos kernel algorithm as described on
|
||||
@ -1,7 +1,7 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
// Copyright (c) Six Labors and contributors.
|
||||
// Licensed under the Apache License, Version 2.0.
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
namespace SixLabors.ImageSharp.Processing |
namespace SixLabors.ImageSharp.Processing.Transforms |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// The function implements the Lanczos kernel algorithm as described on
|
/// The function implements the Lanczos kernel algorithm as described on
|
||||
@ -1,7 +1,7 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
// Copyright (c) Six Labors and contributors.
|
||||
// Licensed under the Apache License, Version 2.0.
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
namespace SixLabors.ImageSharp.Processing |
namespace SixLabors.ImageSharp.Processing.Transforms |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// The function implements the mitchell algorithm as described on
|
/// The function implements the mitchell algorithm as described on
|
||||
@ -1,7 +1,7 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
// Copyright (c) Six Labors and contributors.
|
||||
// Licensed under the Apache License, Version 2.0.
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
namespace SixLabors.ImageSharp.Processing |
namespace SixLabors.ImageSharp.Processing.Transforms |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// The function implements the nearest neighbor algorithm. This uses an unscaled filter
|
/// The function implements the nearest neighbor algorithm. This uses an unscaled filter
|
||||
@ -1,12 +1,12 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
// Copyright (c) Six Labors and contributors.
|
||||
// Licensed under the Apache License, Version 2.0.
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
namespace SixLabors.ImageSharp.Processing |
namespace SixLabors.ImageSharp.Processing.Transforms |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// Enumerates the available orientation values supplied by EXIF metadata.
|
/// Enumerates the available orientation values supplied by EXIF metadata.
|
||||
/// </summary>
|
/// </summary>
|
||||
internal enum Orientation : ushort |
internal enum OrientationType : ushort |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// Unknown rotation.
|
/// Unknown rotation.
|
||||
@ -1,7 +1,7 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
// Copyright (c) Six Labors and contributors.
|
||||
// Licensed under the Apache License, Version 2.0.
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
namespace SixLabors.ImageSharp.Processing |
namespace SixLabors.ImageSharp.Processing.Transforms |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// Contains reusable static instances of known resampling algorithms
|
/// Contains reusable static instances of known resampling algorithms
|
||||
@ -1,7 +1,7 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
// Copyright (c) Six Labors and contributors.
|
||||
// Licensed under the Apache License, Version 2.0.
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
namespace SixLabors.ImageSharp.Processing |
namespace SixLabors.ImageSharp.Processing.Transforms |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// Enumerated resize modes to apply to resized images.
|
/// Enumerated resize modes to apply to resized images.
|
||||
@ -1,7 +1,7 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
// Copyright (c) Six Labors and contributors.
|
||||
// Licensed under the Apache License, Version 2.0.
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
namespace SixLabors.ImageSharp.Processing |
namespace SixLabors.ImageSharp.Processing.Transforms |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// The function implements the Robidoux algorithm.
|
/// The function implements the Robidoux algorithm.
|
||||
@ -1,7 +1,7 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
// Copyright (c) Six Labors and contributors.
|
||||
// Licensed under the Apache License, Version 2.0.
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
namespace SixLabors.ImageSharp.Processing |
namespace SixLabors.ImageSharp.Processing.Transforms |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// The function implements the Robidoux Sharp algorithm.
|
/// The function implements the Robidoux Sharp algorithm.
|
||||
@ -1,7 +1,7 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
// Copyright (c) Six Labors and contributors.
|
||||
// Licensed under the Apache License, Version 2.0.
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
namespace SixLabors.ImageSharp.Processing |
namespace SixLabors.ImageSharp.Processing.Transforms |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// Provides enumeration over how the image should be rotated.
|
/// Provides enumeration over how the image should be rotated.
|
||||
@ -1,7 +1,7 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
// Copyright (c) Six Labors and contributors.
|
||||
// Licensed under the Apache License, Version 2.0.
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
namespace SixLabors.ImageSharp.Processing |
namespace SixLabors.ImageSharp.Processing.Transforms |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// The function implements the spline algorithm.
|
/// The function implements the spline algorithm.
|
||||
@ -1,7 +1,7 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
// Copyright (c) Six Labors and contributors.
|
||||
// Licensed under the Apache License, Version 2.0.
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
namespace SixLabors.ImageSharp.Processing |
namespace SixLabors.ImageSharp.Processing.Transforms |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// The function implements the triangle (bilinear) algorithm.
|
/// The function implements the triangle (bilinear) algorithm.
|
||||
@ -1,7 +1,7 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
// Copyright (c) Six Labors and contributors.
|
||||
// Licensed under the Apache License, Version 2.0.
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
namespace SixLabors.ImageSharp.Processing |
namespace SixLabors.ImageSharp.Processing.Transforms |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// The function implements the welch algorithm.
|
/// The function implements the welch algorithm.
|
||||
@ -1,25 +1,23 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
// Copyright (c) Six Labors and contributors.
|
||||
// Licensed under the Apache License, Version 2.0.
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
using System; |
using SixLabors.ImageSharp.Processing.Transforms; |
||||
using SixLabors.ImageSharp.PixelFormats; |
using SixLabors.ImageSharp.Processing.Transforms.Processors; |
||||
using SixLabors.ImageSharp.Processing.Processors; |
|
||||
using Xunit; |
using Xunit; |
||||
|
|
||||
namespace SixLabors.ImageSharp.Tests.Processing.Transforms |
namespace SixLabors.ImageSharp.Tests.Processing.Transforms |
||||
{ |
{ |
||||
public class EntropyCropTest : BaseImageOperationsExtensionTest |
public class EntropyCropTest : BaseImageOperationsExtensionTest |
||||
{ |
{ |
||||
|
|
||||
[Theory] |
[Theory] |
||||
[InlineData(0.5f)] |
[InlineData(0.5F)] |
||||
[InlineData(.2f)] |
[InlineData(.2F)] |
||||
public void EntropyCrop_threasholdFloat_EntropyCropProcessorWithThreshold(float threashold) |
public void EntropyCropThresholdFloatEntropyCropProcessorWithThreshold(float threshold) |
||||
{ |
{ |
||||
this.operations.EntropyCrop(threashold); |
this.operations.EntropyCrop(threshold); |
||||
var processor = this.Verify<EntropyCropProcessor<Rgba32>>(); |
EntropyCropProcessor<Rgba32> processor = this.Verify<EntropyCropProcessor<Rgba32>>(); |
||||
|
|
||||
Assert.Equal(threashold, processor.Threshold); |
Assert.Equal(threshold, processor.Threshold); |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
Loading…
Reference in new issue