using System;
using OpenCvSharp;

namespace OpenCVStudio_v0
{
    public sealed class FastNlMeansDenoisingColoredExecutor : IImageBlockExecutor
    {
        public string BlockType => "FastNlMeansDenoisingColored";

        public Mat Execute(Mat input, ProjectBlock block, ProjectManager projectManager)
        {
            if (input == null)
                throw new ArgumentNullException(nameof(input));
            if (input.Empty())
            {
                throw new InvalidOperationException("FastNlMeansDenoisingColored: изображение пустое.");
            }
            float h = projectManager.GetBlockParameter(block.Id, "H", 10f);
            float hColor = projectManager.GetBlockParameter(block.Id, "HColor", 10f);
            int templateWindowSize = projectManager.GetBlockParameter(block.Id, "TemplateWindowSize", 7);
            int searchWindowSize = projectManager.GetBlockParameter(block.Id, "SearchWindowSize", 21);
            Mat result = new Mat();
            Cv2.FastNlMeansDenoisingColored(input, result, h, hColor, templateWindowSize, searchWindowSize);
            return result;
        }
    }
}