private void WriteStackV2(int threshold) { WSIExtraction.Stack stack = new WSIExtraction.Stack(); stack.Stackname = this.textBox1.Text; stack.Threshold = threshold; List <int> backgroundColor = new List <int>(); backgroundColor.Add((int)(Math.Round(background_color[0]))); backgroundColor.Add((int)(Math.Round(background_color[1]))); backgroundColor.Add((int)(Math.Round(background_color[2]))); stack.Backgroundcolor = backgroundColor; stack.Resolutionlevel = (int)this.numericUpDown1.Value; List <WSIExtraction.Slice> slices = new List <WSIExtraction.Slice>(); foreach (WSIHistoObject obj in objects) { WSIExtraction.Slice slice = new WSIExtraction.Slice(); slice.Path = obj.labelTitle.Text + ".png"; slice.WsiSourcePath = obj.wsiImagePath; slice.X = obj.objRectangle.X; slice.Y = obj.objRectangle.Y; slice.Width = obj.objRectangle.Width; slice.Height = obj.objRectangle.Height; slices.Add(slice); } stack.Section = slices; ReadWriteUtils.SerializeObjectToJSON(stack, Path.Combine(ApplicationContext.OutputPath, this.textBox1.Text, "stack.json")); // back to normal cursor Cursor.Current = Cursors.Default; MessageBox.Show("Done"); }