public async Task RunAsync(IColorSpace colorSpace, int clusters, string outputDirectory, bool saveColorHistogram) { IsComplete = false; IsRunning = true; var clusterOperation = new BitmapClusterOperation("batch", colorSpace, "_converted"); await clusterOperation.RunAsync(OriginalImage.ToStandardRgbBitmap(), clusters, Path.GetFileNameWithoutExtension(OriginalFilePath), false); outputFileName = GetOutputFileName(OriginalFilePath, outputDirectory, colorSpace, clusters, ".png"); clusterOperation.Bitmap.Save(outputFileName); if (saveColorHistogram) { string histogramOutputDirectory = Path.Combine(outputDirectory, "colorHistograms"); Directory.CreateDirectory(histogramOutputDirectory); SaveWeightedColorsToJson(clusterOperation, histogramOutputDirectory, colorSpace, clusters); } ComputedImage = clusterOperation.Bitmap; ColorWeights = clusterOperation.ColorWeights; Colors = clusterOperation.Colors; IsRunning = false; IsComplete = true; }