void ComputeHistMask(AnElement mask, ROI roi)
    {
        double ex=0,ey=0,ez=0;
        if (DataToHistogramX == null)
        {
            System.out.println("Error : No X-direction present for Histogram !\n");
            return;
        }
          for (int z = 0; z < DataToHistogramX.Sizes[2]; z++) 
            for (int y = 0; y < DataToHistogramX.Sizes[1]; y++) 
                for (int x = 0; x < DataToHistogramX.Sizes[0]; x++) 
                {
                    if (DataToHistogramX != null)
                        ex = DataToHistogramX.GetValueAtOffset(x,y,z,DataToHistogramX);  // always reference to HistoX element in original data
                    if (DataToHistogramY != null)
                        ey = DataToHistogramY.GetValueAtOffset(x,y,z,DataToHistogramX);
                    if (DataToHistogramZ != null)
                        ez = DataToHistogramZ.GetValueAtOffset(x,y,z,DataToHistogramX);
                    if (roi.InROIRange((int)((ex-Offsets[0])/Scales[0] + 0.5),
                                       (int)((ey-Offsets[1])/Scales[1] + 0.5),(int)((ez-Offsets[2])/Scales[2] + 0.5)))
                        mask.SetValueAt(x,y,z,1); // will always be forced to correspond to HistoX data location
                    else
                        mask.SetValueAt(x,y,z,0);
                }
        mask.Max = 1.0;
        mask.Min = 0.0;
        mask.MaxValue = 5.0;
        mask.AlignDisplayTo(DataToHistogramX);
    }