示例#1
0
        private void save_Statistics_Click(object sender, RoutedEventArgs e)
        {
            if (fileNameBox.SelectedIndex == -1)
            {
                throw new System.Exception("No image loaded, cannot export!");
            }

            if (selectionBox.Visibility != Visibility.Visible)
            {
                throw new System.Exception("No selection availible!");
            }

            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter = "TXT files (*.TXT)|*.txt|All files (*.*)|*.*";

            if (saveFileDialog.ShowDialog() == true)
            {
                using (var fileStream = new StreamWriter(saveFileDialog.FileName))
                {
                    ImageSlice slices = _imageData[fileNameBox.SelectedIndex];
                    fileStream.WriteLine("Slice\tAvarage\tStdDev\t#Points\tsizeX({0})\tsizeY({0})\tsizeZ({0})", slices.realUnit);
                    for (int i = 1; i <= slices.zSize; i++)
                    {
                        var r     = convertSelectionToRect(slices);
                        var stats = slices.GetStatistics(r, i);
                        var dim   = slices.GetDimensions(r);
                        fileStream.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t", i,
                                             stats.Item1, stats.Item2, stats.Item3,
                                             dim.Item1, dim.Item2, dim.Item3);
                    }
                }
            }
        }
示例#2
0
        private void statistics(ImageSlice slice)
        {
            if (selectionBox.Width > 0 && selectionBox.Height > 0)
            {
                var r     = convertSelectionToRect(slice);
                var stats = slice.GetStatistics(r, _numSlice);
                var dim   = slice.GetDimensions(r);

                avgImg.Text = (Math.Truncate(stats.Item1 * 1000) / 1000).ToString();
                stdImg.Text = (Math.Truncate(stats.Item2 * 1000) / 1000).ToString();
                noImg.Text  = stats.Item3.ToString();

                xSize.Text = (Math.Truncate(dim.Item1 * 100.0) / 100.0).ToString() +
                             " " + slice.realUnit;
                ySize.Text = (Math.Truncate(dim.Item2 * 100.0) / 100.0).ToString() +
                             " " + slice.realUnit;
                zSize.Text = dim.Item3.ToString() + " " + slice.realUnit;
            }
        }