Add Traingle to ImageHelper
This commit is contained in:
@@ -10,9 +10,14 @@ namespace MarketData.CNNProcessing
|
||||
{
|
||||
public static class BitmapExtensions
|
||||
{
|
||||
// This call is used to generate the training, test, and validation bitmaps..
|
||||
// This call is used to generate the CNN training, test, and validation bitmaps..
|
||||
// I noticed a large difference in the accuracy or the model when the quality parameter is 100.
|
||||
// I therefore intentionally not using EncoderParameters to specify quality but instead taking the default quality.
|
||||
/// <summary>
|
||||
/// Save JPG encoded bitmap
|
||||
/// </summary>
|
||||
/// <param name="bitmap"></param>
|
||||
/// <param name="filename"></param>
|
||||
public static void SaveJPG100(this SKBitmap bitmap, string filename)
|
||||
{
|
||||
if(File.Exists(filename))File.Delete(filename);
|
||||
@@ -22,11 +27,42 @@ namespace MarketData.CNNProcessing
|
||||
encodedImage.SaveTo(stream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save JPG encoded bitmap
|
||||
/// </summary>
|
||||
/// <param name="bitmap"></param>
|
||||
/// <param name="stream"></param>
|
||||
public static void SaveJPG100(this SKBitmap bitmap, Stream stream)
|
||||
{
|
||||
using SKImage image = SKImage.FromBitmap(bitmap);
|
||||
using SKData encodedImage = image.Encode(SKEncodedImageFormat.Jpeg,100);
|
||||
encodedImage.SaveTo(stream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save PNG encoded bitmap
|
||||
/// </summary>
|
||||
/// <param name="bitmap"></param>
|
||||
/// <param name="filename"></param>
|
||||
public static void SavePNG100(this SKBitmap bitmap, string filename)
|
||||
{
|
||||
if(File.Exists(filename))File.Delete(filename);
|
||||
using FileStream stream = new FileStream(filename, FileMode.Create, FileAccess.Write);
|
||||
using SKImage image = SKImage.FromBitmap(bitmap);
|
||||
using SKData encodedImage = image.Encode(SKEncodedImageFormat.Png,100);
|
||||
encodedImage.SaveTo(stream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save PNG encoded bitmap
|
||||
/// </summary>
|
||||
/// <param name="bitmap"></param>
|
||||
/// <param name="stream"></param>
|
||||
public static void SavePNG100(this SKBitmap bitmap, Stream stream)
|
||||
{
|
||||
using SKImage image = SKImage.FromBitmap(bitmap);
|
||||
using SKData encodedImage = image.Encode(SKEncodedImageFormat.Png,100);
|
||||
encodedImage.SaveTo(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user