static void Main(string[] args) { string path = "..\\..\\img\\lena.png"; int[,] imgArray = ImageHelper.LoadImage(path); Console.Write("Rozmiar ramki: "); int frameSize = int.Parse(Console.ReadLine()); //int frameSize = 2; Console.Write("Liczba neuronów: "); int numOfNeurons = int.Parse(Console.ReadLine()); Console.Write("Liczba epok: "); int epochs = int.Parse(Console.ReadLine()); Random random = new Random(); Kohonen kohonen = new Kohonen(frameSize, numOfNeurons, 0.01, random); kohonen.Train(epochs, imgArray); Result result = kohonen.Compress(imgArray); int[,] decompressedImage = Decompress(result); ImageHelper.SaveImage(decompressedImage, "..\\..\\img\\test.png"); double PSNR = Coefficient.PSNR(imgArray, decompressedImage); Console.WriteLine($"Współczynnik PSNR: {PSNR} dB"); double compressionCoefficient = CountCompressionCoefficient(imgArray, frameSize, numOfNeurons, 8); Console.WriteLine($"Współczynnik kompresji: {compressionCoefficient}"); Console.ReadLine(); }
public static double PSNR(int[,] oldImg, int[,] newImg) { double MSE = Coefficient.MSE(oldImg, newImg); return(10 * Math.Log10(Math.Pow(255, 2) / MSE)); }