Beispiel #1
0
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        void userControlMutiDicomImages_ImageNumChanged(object Sender, EventArgs e)
        {
            if (captureImagesNow.Count <= 0)
            {
                return;
            }
            pixelMapData = null;
            int index = userControlMutiDicomImages.SelectedIndex;

            imgROI = captureImagesNow[index];

            pixelMapData = new ushort[imgROI.ImageData.GetLength(0), imgROI.ImageData.GetLength(1)];
            int    Average    = 0;
            long   SumValue   = 0;
            string xmlValue   = CapturePub.readCaptrueValue("UNIT");
            string unit       = (xmlValue == "" ? "4" : xmlValue);
            int    unitlength = int.Parse(unit);

            xmlValue = CapturePub.readCaptrueValue("Coefficient");
            string coefficient = (xmlValue == "" ? "0.9" : xmlValue);
            float  percentage  = float.Parse(coefficient);

            for (int i = 0; i < imgROI.ImageData.GetLength(0) / unitlength; i++)
            {
                for (int j = 0; j < imgROI.ImageData.GetLength(1) / unitlength; j++)
                {
                    Average  = 0;
                    SumValue = 0;
                    for (int ii = 0; ii < unitlength; ii++)
                    {
                        for (int jj = 0; jj < unitlength; jj++)
                        {
                            SumValue += imgROI.ImageData[i * unitlength + ii, j *unitlength + jj];
                        }
                    }
                    Average = (int)(((double)SumValue / (unitlength * unitlength)) * percentage);
                    for (int ii = 0; ii < unitlength; ii++)
                    {
                        for (int jj = 0; jj < unitlength; jj++)
                        {
                            if (imgROI.ImageData[i * unitlength + ii, j *unitlength + jj] >= Average)
                            {
                                pixelMapData[i * unitlength + ii, j *unitlength + jj] = 0;
                            }
                            else
                            {
                                pixelMapData[i * unitlength + ii, j *unitlength + jj] = 65535;
                            }
                        }
                    }
                }
            }

            his.ComputeHistogram(imgROI.ImageData);
            imgROI.GenerateBMP(his.LUT);
            imgShow.InitImageData(imgROI, his, pixelMapData);
            labelMedianValue.Text = "Ave:" + (int)his.AverageValue;
            labelWL.Text          = "L=" + his.windowCenter + ",W=" + his.windowWidth;
        }
Beispiel #2
0
        void his_LUTChanged(Color[] LUT)
        {
            if (imgROI == null || imgROI.ImageData == null)
            {
                return;
            }

            imgROI.GenerateBMP(LUT);
            imgShow.RefreshView();
            labelWL.Text = "L=" + his.windowCenter + ",W=" + his.windowWidth;
        }