private void OutputSegmentations(Workbook wb, string filename, int width, int height) { Worksheet ws = wb.Worksheets[0]; //image reading Bitmap b = new Bitmap(filename); double[,,] arrayImage = BitmapConverter.BitmapToDoubleRgb(b); //MemoryStream memoryStream = new MemoryStream(); //b.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg); //processing cycle int counter = 0; for (int k = kMin, i = 0; k <= kMax; k += kStep, i++) { int currentRow = i * (RowsForDetails + 1) + startImageRowNumber; for (int min = minMin, j = startImageColumnNumber; min <= minMax; min += minStep, j++) { //получение результатов сегментации Segmentation segmentationObj = new Segmentation(); Bitmap res = segmentationObj.DoSegmentation(b, 0.84, k, min, new SegmentationBasedOnGraph.ColorShemes.RGBColorSheme()); //приведение результатов к нужному размеру res = Service.ResizeImage(res, width, height); ///сохранения результата в поток MemoryStream memoryStream = new MemoryStream(); res.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg); //добавления сегментации на страницу ws.Cells[currentRow + 1, j].Value = segmentationObj.m_componentLength.ToString(); int idx = ws.Pictures.Add(currentRow, j, memoryStream); ws.Cells[currentRow + 1, j].Value = $"Сегментів: {segmentationObj.m_componentLength}"; ws.Cells[currentRow + 2, j].Value = $"Сума внутрішньокластерних дисперсій: {segmentationObj.GetInternalDifferenceAssessment().ToString("0.00")}"; counter++; System.Diagnostics.Debug.WriteLine($"Сегментация {counter} посчитана"); } } }