Esempio n. 1
0
        private xrfPixel[][] ExtractElementRelatedPixelData(int beamHeight, int beamWidth, int index, double[][][] sortedData)
        {
            xrfPixel[][] pixelData = new xrfPixel[beamHeight][];

            for (int i = 0; i < beamHeight; i++)
            {
                pixelData[i] = new xrfPixel[beamWidth];
                for (int j = 0; j < beamWidth; j++)
                {
                    double[] row         = sortedData[i][j];
                    double   xActual     = row[2];
                    double   yActual     = row[3];
                    double   xGoal       = row[0];
                    double   yGoal       = row[1];
                    int      counts      = (int)row[index];
                    double   temperature = CalculateGradientTemperature(counts);

                    pixelData[i][j] = new xrfPixel(xActual, yActual, xGoal, yGoal, counts, temperature);
                }
            }

            return(pixelData);
        }
        private void IsolateImageGridUnderZoom(string selectedTag)
        {
            int selectedCenterX, selectedCenterY;
            int height = _baseImageData.Length;
            int width  = _baseImageData[0].Length;

            selectedCenterX = selectedCenterY = 0;

            // search for new approximate center indicated by zoom
            for (int i = 0; i < _baseImageData.Length; i++)
            {
                for (int j = 0; j < _baseImageData[i].Length; j++)
                {
                    if (selectedTag == _baseImageData[i][j].Tag)
                    {
                        selectedCenterY = i;
                        selectedCenterX = j;
                    }
                }
            }

            // get new dimensions
            int heightTemp = height / (int)Zoom;
            int widthTemp  = width / (int)Zoom;
            int newHeight  = (heightTemp >= 1) ? heightTemp : 1;
            int newWidth   = (widthTemp >= 1) ? widthTemp : 1;

            ///////////////////////////////// NOTE TO SELF - REVIEW THIS (BELOW) MESS WHEN AWAKE //////////////////////////////
            // determine new center
            int tempX = newWidth / 2;
            int tempY = newHeight / 2;


            int newCenterX = 0;
            int newCenterY = 0;

            if (((selectedCenterX - tempX) >= 0) && ((selectedCenterX + tempX) < width))
            {
                newCenterX = selectedCenterX;
            }
            else
            {
                if ((selectedCenterX - tempX) < 0)
                {
                    newCenterX = tempX;
                }

                if ((selectedCenterX + tempX) >= width)
                {
                    newCenterX = width - tempX;
                }
            }

            if (((selectedCenterY - tempY) >= 0) && ((selectedCenterY + tempY) < height))
            {
                newCenterY = selectedCenterY;
            }
            else
            {
                if ((selectedCenterY - tempY) < 0)
                {
                    newCenterY = tempY;
                }

                if ((selectedCenterY + tempY) >= height)
                {
                    newCenterY = height - tempY;
                }
            }

            // create a new image data array
            ImageData = new xrfPixel[newHeight][];

            // populate the array
            int tempTlx  = newCenterX - tempX;
            int tempTly  = newCenterY - tempY;
            int maxTlx   = width - newWidth;
            int maxTly   = height - newHeight;
            int topLeftX = (tempTlx <= maxTlx) ? tempTlx : maxTlx;
            int topLeftY = (tempTly <= maxTly) ? tempTly : maxTly;

            ///////////////////////////////// NOTE TO SELF - REVIEW THIS (ABOVE) MESS WHEN AWAKE //////////////////////////////

            for (int i = 0; i < newHeight; i++)
            {
                ImageData[i] = new xrfPixel[newWidth];
                for (int j = 0; j < newWidth; j++)
                {
                    ImageData[i][j] = _baseImageData[topLeftY + i][topLeftX + j];
                }
            }
        }