private Histogramf buildHistogram(IVoxelDataStructure grid, IProgress <int> progress) { Histogramf histogram = new Histogramf(Min, Max, BinCount); int numberOfVoxels = grid.NumberOfVoxels; //Only report every 5% int updateNumber = numberOfVoxels / 20; int voxelNum = 0; foreach (Voxel voxel in grid) { voxelNum++; if (!(grid.ValueUnit == Unit.Gamma && voxel.Value == -1)) { if (UseROI && ROI.ContainsPointNonInterpolated(voxel.Position)) { histogram.AddDataPoint(voxel.Value * grid.Scaling); } else if (!UseROI) { histogram.AddDataPoint(voxel.Value * grid.Scaling); } } if (voxelNum % updateNumber == 0) { progress.Report((int)(100 * ((double)voxelNum / (double)numberOfVoxels))); } } return(histogram); }
private void SetMinMax(IEnumerable <IVoxelDataStructure> grids) { if (AutomaticMinMax) { Max = float.MinValue; Min = float.MaxValue; } foreach (var grid in grids) { foreach (Voxel voxel in grid) { if (!(grid.ValueUnit == Unit.Gamma && voxel.Value == -1)) { if (UseROI && ROI.ContainsPointNonInterpolated(voxel.Position.X, voxel.Position.Y, voxel.Position.Z)) { CompareAndSetMax(voxel.Value * grid.Scaling); CompareAndSetMin(voxel.Value * grid.Scaling); } else if (!UseROI) { CompareAndSetMax(voxel.Value * grid.Scaling); CompareAndSetMin(voxel.Value * grid.Scaling); } } } } }