private void MenuSRGBCalibration_Click(object sender, RoutedEventArgs e)
        {
            selection.width = selection.width / 2 * 2;
            selection.height = selection.height / 2 * 2;
            byte[] pixels = new byte[selection.width * selection.height * 2]; // allocate mem for current pixel data values
            int[] values = new int[selection.width * selection.height]; // color values
            double[] cumSquareDiff = new double[4];

            selection.X = selection.X / 2 * 2; // force even number, otherwise bayer order is not constant
            selection.Y = selection.Y / 2 * 2;

            CroppedBitmap chunk = new CroppedBitmap(bmpSource, new Int32Rect(selection.X, selection.Y, selection.width, selection.height)); // get 2x2 region from source

            try {
                chunk.CopyPixels(pixels, selection.width * 2, 0); // stuff data into 4 pixel (8 byte) array
            } catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }

            stats.calcMacbethStats(pixels, selection.width, selection.height);

            imagestats.colorvals[] macbethMeans = new imagestats.colorvals[24];

            macbethMeans = stats.getMacbethMean();
        }
 private void MenuGetMacBethStats_Click(object sender, RoutedEventArgs e)
 {
     if (stats.imageType == 0) {
         byte[] pixels = getPixelsFromRawImage(new Point(selection.X, selection.Y), selection.width, selection.height);
         stats.calcMacbethStats(pixels, selection.width, selection.height);
         imagestats.colorvals[] macbethMeans = new imagestats.colorvals[24];
         macbethMeans = stats.getMacbethMean();
     } else // BMP
     {
         if (selection.width < 1 || selection.height < 1)
             return;
         byte[] pixels = getPixelsFromBMPImage(new Point(selection.X, selection.Y), selection.width, selection.height);
         stats.calcMacbethStats(pixels, selection.width, selection.height);
         imagestats.colorvals[] macbethMeans = new imagestats.colorvals[24];
         macbethMeans = stats.getMacbethMean();
     }
 }