예제 #1
0
        public cImageDisplayProperties GetImageDisplayProperties()
        {
            cImageDisplayProperties ToReturn = new cImageDisplayProperties();

            ToReturn.ListMin = new List<double>();
            ToReturn.ListMax = new List<double>();
            ToReturn.ListActive = new List<bool>();
            ToReturn.ListLUTNames = new List<string>();
            ToReturn.ListGamma = new List<double>();
            ToReturn.ListOpacity = new List<double>();

            for (int IdxChannel = 0; IdxChannel < this.panelForLUTS.Controls.Count; IdxChannel++)
            {
                UserControlSingleLUT SingleLUT = (UserControlSingleLUT)this.panelForLUTS.Controls[IdxChannel];
                ToReturn.ListMin.Add((double)SingleLUT.numericUpDownMinValue.Value);
                ToReturn.ListMax.Add((double)SingleLUT.numericUpDownMaxValue.Value);

                ToReturn.ListActive.Add(SingleLUT.checkBoxIsActive.Checked);

                ToReturn.ListLUTNames.Add(SingleLUT.comboBoxForLUT.Text);

                ToReturn.ListGamma.Add(SingleLUT.trackBarGamma.Value);
                ToReturn.ListOpacity.Add(SingleLUT.trackBarOpacity.Value);
            }

            return ToReturn;
        }
예제 #2
0
        private void ToolStripMenuItem_Morpho_Erode(object sender, EventArgs e)
        {
            cDisplaySingleImage NewView = new cDisplaySingleImage();

            cImageMorphoErode ME = new cImageMorphoErode();
            ME.SetInputData(this.AssociatedImage);
            ME.Iterations = 3;
            ME.Run();
            NewView.SetInputData(ME.GetOutPut());

            NewView.Run();

            cImageDisplayProperties TmpProp = new cImageDisplayProperties();
            TmpProp.UpdateFromLUTManager(this.LUTManager);
            NewView.MyImageViewer.IP.LUTManager.UpdateFromDisplayProperties(TmpProp);
        }
예제 #3
0
        public bool UpdateFromDisplayProperties(cImageDisplayProperties ImageDisplayProperties)
        {
            if (this.panelForLUTS.Controls.Count != ImageDisplayProperties.ListMin.Count)
            {
                return false;
            }

             for (int IdxChannel = 0; IdxChannel < this.panelForLUTS.Controls.Count; IdxChannel++)
            {
                UserControlSingleLUT SingleLUT = (UserControlSingleLUT)this.panelForLUTS.Controls[IdxChannel];

                SingleLUT.UpdateFromDisplayProperties(ImageDisplayProperties, IdxChannel);
                //SingleLUT.numericUpDownMinValue.Value = (decimal)ImageDisplayProperties.ListMin[IdxChannel];
                //SingleLUT.numericUpDownMaxValue.Value = (decimal)ImageDisplayProperties.ListMax[IdxChannel];
                //SingleLUT.checkBoxIsActive.Checked = ImageDisplayProperties.ListActive[IdxChannel];
                //SingleLUT.comboBoxForLUT.Text = ImageDisplayProperties.ListLUT[IdxChannel];
            }

             return true;
        }
예제 #4
0
        private void ToolStripMenuItem_GeometricalFlip(object sender, EventArgs e)
        {
            cDisplaySingleImage NewView = new cDisplaySingleImage();

            cImageGeometricFlip GF = new cImageGeometricFlip();
            GF.SetInputData(this.AssociatedImage);

            GF.ListProperties.FindByName("Horizontal").SetNewValue((bool)true);
            GF.ListProperties.FindByName("Horizontal").IsGUIforValue = true;
            cFeedBackMessage FeedBackMessage = GF.Run();

            cGlobalInfo.WindowHCSAnalyzer.richTextBoxConsole.AppendText(FeedBackMessage.GetFullFeedBack());
            if (FeedBackMessage.IsSucceed == false) return;

            cImageDisplayProperties TmpProp = new cImageDisplayProperties();
            TmpProp.UpdateFromLUTManager(this.LUTManager);

            NewView.SetInputData(GF.GetOutPut());
            NewView.Run();

            //NewView.LUTManager.UpdateFromDisplayProperties(TmpProp);
        }
예제 #5
0
        private void ToolStripMenuItem_GeometricalResize(object sender, EventArgs e)
        {
            cDisplaySingleImage NewView = new cDisplaySingleImage();

            cImageGeometricResize GR = new cImageGeometricResize();
            GR.SetInputData(this.AssociatedImage);
            GR.SliceIndex = (int)ZNavigator.numericUpDownZPos.Value;
            GR.InterpolationType = Emgu.CV.CvEnum.Inter.Linear;

            GR.ListProperties.FindByName("Scale").SetNewValue((double)0.5);
            GR.ListProperties.FindByName("Scale").IsGUIforValue = true;

            GR.ListProperties.FindByName("Maximum Width").SetNewValue((int)0);
            GR.ListProperties.FindByName("Maximum Width").IsGUIforValue = true;

            cFeedBackMessage FeedBackMessage = GR.Run();

            cGlobalInfo.WindowHCSAnalyzer.richTextBoxConsole.AppendText(FeedBackMessage.GetFullFeedBack());
            if (FeedBackMessage.IsSucceed == false) return;

            cImageDisplayProperties TmpProp = new cImageDisplayProperties();
            TmpProp.UpdateFromLUTManager(this.LUTManager);

            NewView.SetInputData(GR.GetOutPut());
            NewView.Run();

            //NewView.LUTManager.UpdateFromDisplayProperties(TmpProp);
        }
예제 #6
0
        private void ToolStripMenuItem_Filtering_Median(object sender, EventArgs e)
        {
            cDisplaySingleImage NewView = new cDisplaySingleImage();

            cImageFilterMedian FM = new cImageFilterMedian();
            FM.SetInputData(this.AssociatedImage);

            FM.ListProperties.FindByName("Kernel Size").SetNewValue((int)5);
            FM.ListProperties.FindByName("Kernel Size").IsGUIforValue = true;
            cFeedBackMessage FeedBackMessage = FM.Run();

            //GlobalInfo.WindowHCSAnalyzer.richTextBoxConsole.AppendText(FeedBackMessage.GetFullFeedBack());
            if (FeedBackMessage.IsSucceed == false) return;

            NewView.SetInputData(FM.GetOutPut());

            NewView.Run();

            cImageDisplayProperties TmpProp = new cImageDisplayProperties();
            TmpProp.UpdateFromLUTManager(this.LUTManager);
            NewView.MyImageViewer.IP.LUTManager.UpdateFromDisplayProperties(TmpProp);

            //GlobalInfo.DisplayViewer(NewView);
        }
예제 #7
0
        private void ToolStripMenuItem_GeometricalCrop(object sender, EventArgs e)
        {
            cDisplaySingleImage NewView = new cDisplaySingleImage();

            Point Bottom = new Point(mRect.Left, mRect.Top);
            Point ConvertedBottom = ConvertPanelCoordToImageCoord(Bottom);

            Point Top = new Point(mRect.Right, mRect.Bottom);
            Point ConvertedTop = ConvertPanelCoordToImageCoord(Top);

            cImage CroppedImage = this.AssociatedImage.Crop(new cPoint3D(ConvertedBottom.X, ConvertedBottom.Y, 0), new cPoint3D(ConvertedTop.X, ConvertedTop.Y, 0));

            cImageDisplayProperties TmpProp = new cImageDisplayProperties();
            TmpProp.UpdateFromLUTManager(this.LUTManager);

            NewView.SetInputData(CroppedImage);
            NewView.Run();
            NewView.MyImageViewer.IP.LUTManager.UpdateFromDisplayProperties(TmpProp);
        }
예제 #8
0
        private void ToolStripMenuItem_Filtering_GaussianConvolution(object sender, EventArgs e)
        {
            cDisplaySingleImage NewView = new cDisplaySingleImage();

            ImageAnalysisFiltering.cImageFilterGaussianConvolution GaussianBlur = new ImageAnalysisFiltering.cImageFilterGaussianConvolution();
            GaussianBlur.SetInputData(this.AssociatedImage);
            GaussianBlur.ListProperties.FindByName("Kernel Size").SetNewValue((int)3);
            GaussianBlur.ListProperties.FindByName("Kernel Size").IsGUIforValue = true;
            cFeedBackMessage FeedBackMessage = GaussianBlur.Run();
            if (FeedBackMessage.IsSucceed == false) return;
            NewView.SetInputData(GaussianBlur.GetOutPut());

            NewView.Run();

            cImageDisplayProperties TmpProp = new cImageDisplayProperties();
            TmpProp.UpdateFromLUTManager(this.LUTManager);
            NewView.MyImageViewer.IP.LUTManager.UpdateFromDisplayProperties(TmpProp);
        }
예제 #9
0
        private void ToolStripMenuItem_AddNoise(object sender, EventArgs e)
        {
            cDisplaySingleImage NewView = new cDisplaySingleImage();

            cImageAddNoise AN = new cImageAddNoise();
            AN.SetInputData(this.AssociatedImage);
            AN.DistributionType = Classes.Base_Classes.Data.eRandDistributionType.GAUSSIAN;
            AN.Mean = 0;
            AN.Stdev = 10;
            //FLM.DistanceType = Emgu.CV.CvEnum.DIST_TYPE.CV_DIST_L2;
            AN.Run();
            NewView.SetInputData(AN.GetOutPut());

            NewView.Run();

            cImageDisplayProperties TmpProp = new cImageDisplayProperties();
            TmpProp.UpdateFromLUTManager(this.LUTManager);

            NewView.MyImageViewer.IP.LUTManager.UpdateFromDisplayProperties(TmpProp);
        }
예제 #10
0
        cFeedBackMessage Process()
        {
            if (base.Start() == false)
            {
                base.FeedBackMessage.IsSucceed = false;
                return base.FeedBackMessage;
            }

            object _firstValue = base.ListProperties.FindByName("Include Images?");
            bool IsIncludeImages = false;
            if (_firstValue == null)
            {
                base.GenerateError("-Include Images?- not found !");
                return base.FeedBackMessage;
            }
            try
            {
                cProperty TmpProp = (cProperty)_firstValue;
                IsIncludeImages = (bool)TmpProp.GetValue();
            }
            catch (Exception)
            {
                base.GenerateError("-Include Images?- cast didn't work");
                return base.FeedBackMessage;
            }

            this.Output = this.Input.GetAverageDescriptorValuesFull();

            if (IsIncludeImages)
            {
                this.Output.ListTags = new List<object>();

                foreach (cWell item in Input)
                {
                    cGetImageFromWells GIFW = new cGetImageFromWells();
                    GIFW.SetInputData(new cListWells(this));
                    if (!GIFW.Run().IsSucceed) continue;
                    cImage AccessedImage = GIFW.GetOutPut();

                    List<byte[][]> ListLUTs = new List<byte[][]>();
                    cLUT LUT = new cLUT();
                    ListLUTs.Add(LUT.LUT_LINEAR_RED);
                    ListLUTs.Add(LUT.LUT_LINEAR_GREEN);
                    ListLUTs.Add(LUT.LUT_LINEAR_BLUE);

                    List<double> ListMin = new List<double>();
                    ListMin.Add(200);
                    ListMin.Add(200);

                    List<double> ListMax = new List<double>();
                    ListMax.Add(65530);
                    ListMax.Add(5000);

                    cImageDisplayProperties IP = new cImageDisplayProperties();
                    IP.ListMax = ListMax;
                    IP.ListMin = ListMin;

                    this.Output.ListTags.Add(AccessedImage.GetBitmap(0.2f, IP, ListLUTs));
                }

            }

            base.End();

            return FeedBackMessage;

            //// here is the core of the meta component ...
            //// just a list of Component steps
            //foreach (cWell item in Input)
            //{
            //    item.AssociatedPlate.DBConnection = new cDBConnection(item.AssociatedPlate, item.SQLTableName);
            //    cListSingleBiologicalObjects ListPhenotypes = item.AssociatedPlate.DBConnection.GetBiologicalPhenotypes(item);
            //    cExtendedTable ET = item.AssociatedPlate.DBConnection.GetWellValues(item, cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptors());
            //    item.AssociatedPlate.DBConnection.CloseConnection();

            //    ET.ListTags = new List<object>();

            //    for (int i = 0; i < ET.Count; i++)
            //    {
            //        ET[i].ListTags = new List<object>();

            //        for (int j = 0; j < ListPhenotypes.Count; j++)
            //            ET[i].ListTags.Add(ListPhenotypes[j]);
            //    }

            //    for (int j = 0; j < ListPhenotypes.Count; j++)
            //        ET.ListTags.Add(ListPhenotypes[j]);

            //    if (Output == null)
            //        Output = new cExtendedTable(ET);
            //    else
            //    {
            //        cMerge M = new cMerge();
            //        M.IsHorizontal = false;
            //        M.SetInputData(Output, ET);
            //        M.Run();

            //        Output = M.GetOutPut();
            //    }
            //}
        }
예제 #11
0
파일: cImage.cs 프로젝트: cyrenaique/HCSA
        /// <summary>
        /// Build a BITMAP from a cImage
        /// </summary>
        /// <param name="ZoomFactor"></param>
        /// <param name="ListMin">Minimum values for each band (if NULL then automatically computed)</param>
        /// <param name="ListMax">Maximum values for each band (if NULL then automatically computed)</param>
        /// <param name="ListLUTs">use  cLUT ListLUT = new cLUT() to build your LUT</param>
        /// <returns></returns>
        public Bitmap GetBitmap(float ZoomFactor, cImageDisplayProperties ImageDisplayProperties, List<byte[][]> ListLUTs)
        {

            if ((this.Width == 0) || (this.Height == 0)) return null;

            if (ListLUTs == null)
            {
                ListLUTs = new List<byte[][]>();
                cLUT LUT = new cLUT();

                if (this.GetNumChannels() == 1)
                {
                    ListLUTs.Add(LUT.LUT_LINEAR);
                }
                else if (this.GetNumChannels() == 2)
                {
                    ListLUTs.Add(LUT.LUT_LINEAR_RED);
                    ListLUTs.Add(LUT.LUT_LINEAR_GREEN);
                }
                else if (this.GetNumChannels() == 3)
                {
                    ListLUTs.Add(LUT.LUT_LINEAR_RED);
                    ListLUTs.Add(LUT.LUT_LINEAR_GREEN);
                    ListLUTs.Add(LUT.LUT_LINEAR_BLUE);
                }
                else
                {
                    ListLUTs.Add(LUT.LUT_LINEAR_RED);
                    ListLUTs.Add(LUT.LUT_LINEAR_GREEN);
                    ListLUTs.Add(LUT.LUT_LINEAR_BLUE);
                    for (int i = 0; i < this.GetNumChannels() - 3; i++)
                    {
                        ListLUTs.Add(LUT.LUT_LINEAR);
                    }
                }
            }

            List<double> ListMax = new List<double>();
            List<double> ListMin = new List<double>();

            if (ImageDisplayProperties != null)
            {
                if (ImageDisplayProperties.ListMax == null)
                {
                    for (int i = 0; i < this.GetNumChannels(); i++)
                    {
                        this.SingleChannelImage[i].UpDateMax();
                        ListMax.Add(this.SingleChannelImage[i].Max);
                    }
                }
                else
                    ListMax = ImageDisplayProperties.ListMax;

                if (ImageDisplayProperties.ListMin == null)
                {
                    for (int i = 0; i < this.GetNumChannels(); i++)
                    {
                        this.SingleChannelImage[i].UpDateMin();
                        ListMin.Add(this.SingleChannelImage[i].Min);
                    }
                }
                else
                    ListMin = ImageDisplayProperties.ListMin;

            }
            else
            {
                for (int i = 0; i < this.GetNumChannels(); i++)
                {
                    this.SingleChannelImage[i].UpDateMax();
                    ListMax.Add(this.SingleChannelImage[i].Max);
                }

                for (int i = 0; i < this.GetNumChannels(); i++)
                {
                    this.SingleChannelImage[i].UpDateMin();
                    ListMin.Add(this.SingleChannelImage[i].Min);
                }

            }

            List<bool> ListActive = null;

            if ((ImageDisplayProperties == null) || (ImageDisplayProperties.ListActive == null))
            {
                ListActive = new List<bool>();
                for (int i = 0; i < this.GetNumChannels(); i++)
                {
                    ListActive.Add(true);
                }
            }
            else
                ListActive = ImageDisplayProperties.ListActive;

            int NewWidth = (int)(this.Width * ZoomFactor);
            int NewHeight = (int)(this.Height * ZoomFactor);

            Bitmap BMPToBeReturned = new Bitmap(NewWidth, NewHeight, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

            // Lock the bitmap's bits.  
            Rectangle rect = new Rectangle(0, 0, NewWidth, NewHeight);
            System.Drawing.Imaging.BitmapData bmpData = BMPToBeReturned.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite, BMPToBeReturned.PixelFormat);

            // Get the address of the first line.
            IntPtr ptr = bmpData.Scan0;

            int scanline = Math.Abs(bmpData.Stride);

            int bytes = scanline * NewHeight;
            byte[] rgbValues = new byte[bytes];

            byte CurrentRed;
            byte CurrentGreen;
            byte CurrentBlue;

            int RealX;
            int RealY;

            // Copy the RGB values into the array.
            System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes);

            for (int IdxChannel = 0; IdxChannel < this.GetNumChannels(); IdxChannel++)
            {
                if (!ListActive[IdxChannel]) continue;
                byte[][] CurrentLUT = ListLUTs[IdxChannel];

                for (int FullY = 0; FullY < NewHeight; FullY++)
                {
                    RealY = (int)(FullY / ZoomFactor);
                    if (RealY >= this.Height) RealY = this.Height - 1;

                    for (int FullX = 0; FullX < NewWidth; FullX++)
                    {
                        RealX = (int)(FullX / ZoomFactor);
                        if (RealX >= this.Width) RealX = this.Width - 1;

                        float Value = this.SingleChannelImage[IdxChannel].Data[RealX + RealY * this.Width];

                        int ConvertedValue = (int)((((CurrentLUT[0].Length - 1) * (Value - ListMin[IdxChannel]))
                                                    / (ListMax[IdxChannel] - ListMin[IdxChannel])));

                        if (ConvertedValue < 0) ConvertedValue = 0;
                        if (ConvertedValue >= CurrentLUT[0].Length) ConvertedValue = CurrentLUT[0].Length - 1;

                        CurrentRed = (byte)CurrentLUT[0][ConvertedValue];
                        CurrentGreen = (byte)CurrentLUT[1][ConvertedValue];
                        CurrentBlue = (byte)CurrentLUT[2][ConvertedValue];

                        double NewValue = rgbValues[3 * FullX + FullY * scanline] + CurrentBlue;
                        if (NewValue > 255)
                            rgbValues[3 * FullX + FullY * scanline] = 255;
                        else
                            rgbValues[3 * FullX + FullY * scanline] += CurrentBlue;

                        NewValue = rgbValues[3 * FullX + 1 + FullY * scanline] + CurrentGreen;
                        if (NewValue > 255)
                            rgbValues[3 * FullX + 1 + FullY * scanline] = 255;
                        else
                            rgbValues[3 * FullX + 1 + FullY * scanline] += CurrentGreen;

                        NewValue = rgbValues[3 * FullX + 2 + FullY * scanline] + CurrentRed;
                        if (NewValue > 255)
                            rgbValues[3 * FullX + 2 + FullY * scanline] = 255;
                        else
                            rgbValues[3 * FullX + 2 + FullY * scanline] += CurrentRed;
                    }
                }
            }

            // Copy the RGB values back to the bitmap
            System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, ptr, bytes);

            // Unlock the bits.
            BMPToBeReturned.UnlockBits(bmpData);

            return BMPToBeReturned;
        }
예제 #12
0
        public void UpdateFromDisplayProperties(cImageDisplayProperties ImageDisplayProperties, int IdxChannel)
        {
            // this.numericUpDownMaxValue.ValueChanged -=  new EventHandler(numericUpDownMaxValue_ValueChanged);
            this.numericUpDownMaxValue.Value = (decimal)ImageDisplayProperties.ListMax[IdxChannel];
            //   this.numericUpDownMaxValue.ValueChanged +=  new EventHandler(numericUpDownMaxValue_ValueChanged);
            //   this.comboBoxForLUT.SelectedIndexChanged -= new EventHandler(comboBoxForLUT_SelectedIndexChanged);

            //   this.comboBoxForLUT.SelectedIndexChanged += new EventHandler(comboBoxForLUT_SelectedIndexChanged);

            //   this.numericUpDownMinValue.ValueChanged -= new EventHandler(numericUpDownMinValue_ValueChanged);
            this.numericUpDownMinValue.Value = (decimal)ImageDisplayProperties.ListMin[IdxChannel];
            //   this.numericUpDownMinValue.ValueChanged += new EventHandler(numericUpDownMinValue_ValueChanged);

            //   this.checkBoxIsActive.CheckedChanged -= new EventHandler(checkBoxIsActive_CheckedChanged);
            this.checkBoxIsActive.Checked = ImageDisplayProperties.ListActive[IdxChannel];
            //  this.checkBoxIsActive.CheckedChanged += new EventHandler(checkBoxIsActive_CheckedChanged);

            this.comboBoxForLUT.Text = ImageDisplayProperties.ListLUTNames[IdxChannel];

            this.trackBarOpacity.Value = (int)ImageDisplayProperties.ListOpacity[IdxChannel];
            this.trackBarGamma.Value = (int)ImageDisplayProperties.ListGamma[IdxChannel];
        }