Exemple #1
0
        private float[] ComputeSimpleStationarity(Image3D Input, out float Std, int NumIter, int NumPoint)
        {
            float[] Table = new float[NumIter];
            float[] TmpTable = new float[NumPoint];

            Random r = new Random();
            for (int Iter = 0; Iter < NumIter; Iter++)
            {

                for (int RandIdx = 0; RandIdx < NumPoint; RandIdx++)
                {
                    TmpTable[RandIdx] = Input.Data[0][(int)r.Next(0, Input.ImageSize)];
                }

                Table[Iter] = new IM.Library.Mathematics.MathTools().Mean(TmpTable);
            }

            Std = new IM.Library.Mathematics.MathTools().Std(Table);
            return Table;
        }
Exemple #2
0
        private float[] ComputePseudoMonteCarloStatioUnderPoissonNoiseByEmpiricalModeDecomp(Image3D Input, out float Mean, out float Std, int StartIter, int EndIter)
        {
            float[] Table = new float[EndIter - StartIter + 1];

            Random r = new Random();
            for (int Iter = StartIter; Iter <= EndIter; Iter++)
            {
                float[] TmpTable = new float[Iter];
                for (int RandIdx = 0; RandIdx < Iter; RandIdx++)
                {
                    TmpTable[RandIdx] = Input.Data[0][(int)r.Next(0, Input.ImageSize)];
                }

                Table[Iter - StartIter] = new IM.Library.Mathematics.MathTools().Mean(TmpTable);
            }

            Mean = new IM.Library.Mathematics.MathTools().Mean(Table);
            Std = new IM.Library.Mathematics.MathTools().Std(Table);
            return Table;
        }
Exemple #3
0
        private void meanValuesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ListView.SelectedIndexCollection indexes = this.listViewHeap.SelectedIndices;
            if (indexes.Count == 0) return;

            //Image3D Result = new Image3D(((Image3D)(this.listViewHeap.Items[indexes[0]].Tag)).Width,
            //    ((Image3D)(this.listViewHeap.Items[indexes[0]].Tag)).Height,
            //    ((Image3D)(this.listViewHeap.Items[indexes[0]].Tag)).Depth,
            //    ((Image3D)(this.listViewHeap.Items[indexes[0]].Tag)).NumBands);

            int indexesCount = indexes.Count;
            string sMeanValues;
            float CurrentMean;
            Console.WriteLine("Mean values:");
            for (int i = 0; i < indexesCount; i++)
            {
                Image3D TmpIm = ((Image3D)(this.listViewHeap.Items[indexes[i]].Tag));

                int NumChannel = TmpIm.NumBands;
                sMeanValues = "";
                for (int Band = 0; Band < NumChannel; Band++)
                {
                    CurrentMean = new IM.Library.Mathematics.MathTools().Mean(TmpIm.Data[Band]);
                    sMeanValues += CurrentMean.ToString();
                    sMeanValues += " ";
                }
                Console.WriteLine(sMeanValues);

            }
        }
Exemple #4
0
        private string UpdateInfoPicture(Image3D ImageToProcess)
        {
            string textBoxInfoPictureText;

            if (ImageToProcess == null)
            {
                textBoxInfoPicture.Text = "No picture selected";
                textBoxImageName.Enabled = false;
                numericUpDownChannelForHisto.Enabled = false;
                radioButtonHistoTypeClassic.Enabled = false;
                radioButtonHistoTypeCumulated.Enabled = false;
                UpdateHisto(null, 0);
                return "";
            }

            textBoxImageName.Enabled = true;
            //textBoxImageName.Text = ImageToProcess.Name;
            textBoxInfoPictureText = "Width : " + ImageToProcess.Width.ToString() + "\r\n";
            textBoxInfoPictureText += "Height : " + ImageToProcess.Height.ToString() + "\r\n";
            textBoxInfoPictureText += "Depth : " + ImageToProcess.Depth.ToString() + "\r\n";
            textBoxInfoPictureText += "Number of channels : " + ImageToProcess.NumBands.ToString() + "\r\n";
            textBoxInfoPictureText += "X Scale : " + ImageToProcess.XResolution + "\r\n";
            textBoxInfoPictureText += "Y Scale : " + ImageToProcess.YResolution + "\r\n";
            textBoxInfoPictureText += "Z Scale : " + ImageToProcess.ZResolution + "\r\n";

            float TmpValue;
            for (int channel = 0; channel < ImageToProcess.NumBands; channel++)
            {
                textBoxInfoPictureText += "----------------------\r\n";

                textBoxInfoPictureText += "Channel " + channel.ToString() + "\r\n";
                float minValue = new IM.Library.Mathematics.MathTools().Min(ImageToProcess.Data[channel]);
                textBoxInfoPictureText += "Min : " + minValue.ToString() + "\r\n";

                float maxValue = new IM.Library.Mathematics.MathTools().Max(ImageToProcess.Data[channel]);
                textBoxInfoPictureText += "Max : " + maxValue.ToString() + "\r\n";

                TmpValue = new IM.Library.Mathematics.MathTools().Mean(ImageToProcess.Data[channel]);
                textBoxInfoPictureText += "Mean : " + TmpValue.ToString() + "\r\n";

                TmpValue = new IM.Library.Mathematics.MathTools().Std(ImageToProcess.Data[channel]);
                textBoxInfoPictureText += "Std : " + TmpValue.ToString() + "\r\n";

                TmpValue = new IM.Library.Mathematics.MathTools().MAD(ImageToProcess.Data[channel], true);
                textBoxInfoPictureText += "MAD : " + TmpValue.ToString() + "\r\n";

                TmpValue = new IM.Library.Mathematics.MathTools().Median(ImageToProcess.Data[channel], 0, ImageToProcess.ImageSize - 1);
                textBoxInfoPictureText += "Median : " + TmpValue.ToString() + "\r\n";

                TmpValue = new IM.Library.Mathematics.MathTools().Skew(ImageToProcess.Data[channel]);
                textBoxInfoPictureText += "Skewness : " + TmpValue.ToString() + "\r\n";

                TmpValue = new IM.Library.Mathematics.MathTools().Kurt(ImageToProcess.Data[channel]);
                textBoxInfoPictureText += "Kurtosis : " + TmpValue.ToString() + "\r\n";

            }

            UpdateHisto(ImageToProcess, (int)numericUpDownChannelForHisto.Value);
            textBoxInfoPicture.Text = textBoxInfoPictureText;

            return textBoxInfoPictureText;
        }
Exemple #5
0
        private void lastStationarityToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ListView.SelectedIndexCollection indexes = this.listViewHeap.SelectedIndices;
            if (indexes.Count == 0) return;

            bool IsDisplayLevels = true;

            float Mean, Std;
            int indexesCount = indexes.Count;
            int NumIter = 4;

            int WindowsWidth;
            int WindowsHeight;
            float factor = 2;

            float[] ResTotal0 = new float[indexesCount];
            float[] ResTotal1 = new float[indexesCount];
            for (int i = 0; i < indexesCount; i++)
            {
                ResTotal0[i] = ResTotal1[i] = 0.0f;

                Image3D TmpIm = ((Image3D)(this.listViewHeap.Items[indexes[i]].Tag));
                for (int Iter = 1; Iter <= NumIter; Iter++)
                {

                    factor = (float)Math.Pow(2, (double)Iter);
                    WindowsWidth = (int)(TmpIm.Width / factor);
                    WindowsHeight = (int)(TmpIm.Height / factor);

                    float[] ROI = new float[WindowsWidth * WindowsHeight];
                    float[] StdTable = new float[(int)factor * (int)factor];
                    float[] MeanTable = new float[(int)factor * (int)factor];

                    int PosROI = 0;
                    for (int StartWindowsY = 0; StartWindowsY < factor; StartWindowsY++)
                    {
                        int StartPosY = StartWindowsY * WindowsHeight;

                        for (int StartWindowsX = 0; StartWindowsX < factor; StartWindowsX++)
                        {
                            int IdxRoi = 0;
                            int StartPosX = StartWindowsX * WindowsWidth;
                            for (int RealY = StartPosY; RealY < StartPosY + WindowsHeight; RealY++)
                            {
                                for (int RealX = StartPosX; RealX < StartPosX + WindowsWidth; RealX++)
                                {
                                    ROI[IdxRoi++] = TmpIm.Data[0][RealX + RealY * TmpIm.Width];
                                }
                            }

                            //Console.WriteLine("Region ("+StartWindowsX+";"+StartWindowsY+")="+(new IM.Library.Mathematics.MathTools().Mean(ROI)).ToString());
                            StdTable[PosROI] = new IM.Library.Mathematics.MathTools().Std(ROI);
                            MeanTable[PosROI++] = new IM.Library.Mathematics.MathTools().Mean(ROI);

                        }

                    }
                    float cv0;
                    float GlobalMean0 = new IM.Library.Mathematics.MathTools().Mean(MeanTable);
                    float GlobalStd0 = new IM.Library.Mathematics.MathTools().Std(MeanTable);

                    float cv1;
                    float GlobalMean1 = new IM.Library.Mathematics.MathTools().Mean(StdTable);
                    float GlobalStd1 = new IM.Library.Mathematics.MathTools().Std(StdTable);

                    cv0 = GlobalStd0 / GlobalMean0;
                    cv1 = GlobalStd1 / GlobalMean1;
                    if (IsDisplayLevels)
                    {
                        Console.WriteLine("Level " + Iter + ", cv_mean = " + cv0);
                        Console.WriteLine("Level " + Iter + ", cv_std = " + cv1);

                    }
                    ResTotal0[i] += (cv0 / (float)Iter);
                    ResTotal1[i] += (cv1 / (float)Iter);

                    //Image3D ResImage = new Image3D(TmpIm.Width,TmpIm.Height,1,2);

                    //new IM.Library.IO.DataToTextWriter().WriteInColumn(ResImage.Data[0], "D:\\resStation" + i, true);
                    //Sequence TmpSeq = new Sequence();
                    //TmpSeq.Add(ResImage);
                    //IMGlobal.AddSequence(TmpSeq);
                }
                ResTotal0[i] *= 100.0f;
                ResTotal1[i] *= 100.0f;

            }

            for (int i = 0; i < indexesCount; i++)
                Console.WriteLine(/*"Stationarity " + NumIter + " levels (mean) = " + */ResTotal0[i]);

            Console.WriteLine(" ");

            for (int i = 0; i < indexesCount; i++)
                Console.WriteLine(/*"Stationarity " + NumIter + " levels (std) = " + */ResTotal1[i]);
        }