35 lines
980 B
C#
35 lines
980 B
C#
using SkiaSharp;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace DigitalImageProcessing
|
|
{
|
|
public static class HSI
|
|
{
|
|
public static void Run()
|
|
{
|
|
string imagepath = @"C:\Users\Surface\Downloads\" + @"1682575881230001.png";
|
|
SKBitmap bitmap1 = GLobalTools.GetGray(imagepath);
|
|
Image2D<bool> image1 = new(bitmap1.Width, bitmap1.Height);
|
|
for (int x = 0; x < bitmap1.Width; x++)
|
|
{
|
|
for (int y = 0; y < bitmap1.Height; y++)
|
|
{
|
|
SKColor color1 = bitmap1.GetPixel(x, y);
|
|
color1.ToHsi(out int h, out int s, out int i);
|
|
SKColor color2 = new SKColor(
|
|
(byte)(h * 256f / 360f),
|
|
(byte)(s * 256f / 100f),
|
|
(byte)(i * 256f / 100f));
|
|
bitmap1.SetPixel(x, y, color2);
|
|
}
|
|
}
|
|
using FileStream fs = new(@"C:\Users\Surface\Downloads\" + "output_hsi.png", FileMode.Create, FileAccess.Write);
|
|
bitmap1.Encode(fs, SKEncodedImageFormat.Png, 100);
|
|
}
|
|
}
|
|
}
|