Пример #1
0
        private void CreateCurveForGreylevelImageLineData(Point start, Point end)
        {
            TileView viewer = this.mosaicWindow.TileView;

            List <Tile> tiles = viewer.GetVisibleTiles();

            if (tiles == null)
            {
                return;
            }

            if (MosaicWindow.MosaicInfo.ColorDepth >= 24)
            {
                return;
            }

            int max_pixels = Math.Abs((end.X - start.X)) + Math.Abs((end.Y - start.Y));

            double[] values = new double[max_pixels];

            int len = 0;

            foreach (Tile tile in tiles)
            {
                if (tile.IsDummy)
                {
                    continue;
                }

                FreeImageAlgorithmsBitmap dib = tile.LoadFreeImageBitmap();

                len = dib.GetGreyScalePixelValuesAsDoublesForLine(start, end, out values);

                dib.Dispose();
            }

            PointPairList list = new PointPairList();

            double x, y;

            for (int i = 0; i < len; i++)
            {
                x = (double)i;
                y = (double)values[i];
                list.Add(x, y);
            }

            if (this.curve != null)
            {
                this.zedGraphControl.GraphPane.CurveList.Remove(this.curve);
            }

            this.curve = new LineItem("Profile", list, Color.Black, SymbolType.None);

            this.zedGraphControl.GraphPane.CurveList.Insert(0, curve);

            this.zedGraphControl.AxisChange();
        }
Пример #2
0
        public void UpdateGraphForLoadedImage()
        {
            TileView viewer = this.mosaicWindow.TileView;

//            CalculateGreyLevelHistogramShape();

            double min_in_images = Double.MaxValue, max_in_images = Double.MinValue;
            double max_posible_intensity = 0.0;

            if (MosaicWindow.MosaicInfo.IsColour)
            {
                return;
            }

            if (viewer.CacheImageAvailiable)
            {
                max_posible_intensity = viewer.CacheImage.MaximumPossibleIntensityValue;
                viewer.CacheImage.FindMinMaxIntensity(out min_in_images, out max_in_images);
            }
            else
            {
                List <Tile> tiles = viewer.GetVisibleTiles();

                if (tiles == null)
                {
                    return;
                }

                foreach (Tile tile in tiles)
                {
                    if (tile.IsDummy)
                    {
                        continue;
                    }

                    FreeImageAlgorithmsBitmap dib = tile.LoadFreeImageBitmap();

                    if (max_posible_intensity == 0.0)
                    {
                        max_posible_intensity = dib.MaximumPossibleIntensityValue;
                    }

                    double min;
                    double max;

                    dib.FindMinMaxIntensity(out min, out max);

                    if (min < min_in_images)
                    {
                        min_in_images = min;
                    }

                    if (max > max_in_images)
                    {
                        max_in_images = max;
                    }

                    dib.Dispose();
                }
            }

            this.min          = min_in_images;
            this.max          = max_in_images;
            this.max_possible = max_posible_intensity;

            this.minNumericUpDown.Minimum = Convert.ToDecimal(0);
            this.maxNumericUpDown.Minimum = Convert.ToDecimal(1);
            this.minNumericUpDown.Maximum = Convert.ToDecimal(this.max_possible - 1);
            this.maxNumericUpDown.Maximum = Convert.ToDecimal(this.max_possible);
            this.minNumericUpDown.Value   = Convert.ToDecimal(this.min);
            this.maxNumericUpDown.Value   = Convert.ToDecimal(this.max);

            this.zedGraphControl.GraphPane.XAxis.Scale.Min = 0;
            this.zedGraphControl.GraphPane.XAxis.Scale.Max = this.max;
            this.zedGraphControl.GraphPane.YAxis.Scale.Min = 0;
            this.zedGraphControl.GraphPane.YAxis.Scale.Max = 255;

            this.cursor1.Position = this.min;
            this.cursor2.Position = this.max;

            this.DisplayPlot();

            this.zedGraphControl.AxisChange();
        }
        public void UpdateUIForLoadedImage()
        {
            TileView viewer = this.mosaicWindow.TileView;

/*
 *          CalculateGreyLevelHistogramShape(Tile.channel[0], hist_list1, Tile.TotalMaxIntensity[0]);
 *          if (this.histogramCurve1 != null)
 *              this.zedGraphControl1.GraphPane.CurveList.Remove(this.histogramCurve1);
 *          this.histogramCurve1 = this.zedGraphControl1.GraphPane.AddCurve("Histogram", hist_list1, Color.Black, SymbolType.None);
 *          this.histogramCurve1.Line.Fill = new Fill(Color.White, Color.LightSkyBlue, -45F);
 *
 *          CalculateGreyLevelHistogramShape(Tile.channel[1], hist_list2, Tile.TotalMaxIntensity[1]);
 *          if (this.histogramCurve2 != null)
 *              this.zedGraphControl2.GraphPane.CurveList.Remove(this.histogramCurve2);
 *          this.histogramCurve2 = this.zedGraphControl2.GraphPane.AddCurve("Histogram", hist_list2, Color.Black, SymbolType.None);
 *          this.histogramCurve2.Line.Fill = new Fill(Color.White, Color.LightSkyBlue, -45F);
 *
 *          CalculateGreyLevelHistogramShape(Tile.channel[2], hist_list3, Tile.TotalMaxIntensity[2]);
 *          if (this.histogramCurve3 != null)
 *              this.zedGraphControl3.GraphPane.CurveList.Remove(this.histogramCurve3);
 *          this.histogramCurve3 = this.zedGraphControl3.GraphPane.AddCurve("Histogram", hist_list3, Color.Black, SymbolType.None);
 *          this.histogramCurve3.Line.Fill = new Fill(Color.White, Color.LightSkyBlue, -45F);
 */

//            double min_in_images = Double.MaxValue, max_in_images = Double.MinValue;
            double max_posible_intensity = 0.0;

            if (!MosaicWindow.MosaicInfo.IsColour)
            {
                return;
            }

            // load 1 image to get the max possible grey value for the channels
            List <Tile> tiles = viewer.GetVisibleTiles();

            if (tiles == null)
            {
                return;
            }

            FreeImageAlgorithmsBitmap dib = Tile.LoadFreeImageBitmapFromFile(tiles[0].FilePath);  // get on e image from one of the channels

//            max_posible_intensity = dib.MaximumPossibleIntensityValue;
            max_posible_intensity = Utilities.guessFibMaxValue(dib);
            dib.Dispose();

            this.min          = 0;
            this.max          = max_posible_intensity;
            this.max_possible = max_posible_intensity;

            this.minNumericUpDown1.Minimum = Convert.ToDecimal(0);
            this.maxNumericUpDown1.Minimum = Convert.ToDecimal(1);
            this.minNumericUpDown1.Maximum = Convert.ToDecimal(this.max_possible - 1);
            this.maxNumericUpDown1.Maximum = Convert.ToDecimal(this.max_possible);
            this.minNumericUpDown2.Minimum = Convert.ToDecimal(0);
            this.maxNumericUpDown2.Minimum = Convert.ToDecimal(1);
            this.minNumericUpDown2.Maximum = Convert.ToDecimal(this.max_possible - 1);
            this.maxNumericUpDown2.Maximum = Convert.ToDecimal(this.max_possible);
            this.minNumericUpDown3.Minimum = Convert.ToDecimal(0);
            this.maxNumericUpDown3.Minimum = Convert.ToDecimal(1);
            this.minNumericUpDown3.Maximum = Convert.ToDecimal(this.max_possible - 1);
            this.maxNumericUpDown3.Maximum = Convert.ToDecimal(this.max_possible);

            this.minNumericUpDown1.Value = Convert.ToDecimal(Tile.scaleMin[0]);
            this.minNumericUpDown2.Value = Convert.ToDecimal(Tile.scaleMin[1]);
            this.minNumericUpDown3.Value = Convert.ToDecimal(Tile.scaleMin[2]);
            this.maxNumericUpDown1.Value = Convert.ToDecimal(Tile.scaleMax[0]);
            this.maxNumericUpDown2.Value = Convert.ToDecimal(Tile.scaleMax[1]);
            this.maxNumericUpDown3.Value = Convert.ToDecimal(Tile.scaleMax[2]);

            this.numericUpDown1X.Value = Convert.ToDecimal(Tile.channelShift[1].X);
            this.numericUpDown1Y.Value = Convert.ToDecimal(Tile.channelShift[1].Y);
            this.numericUpDown2X.Value = Convert.ToDecimal(Tile.channelShift[2].X);
            this.numericUpDown2Y.Value = Convert.ToDecimal(Tile.channelShift[2].Y);

            this.channelTitle1.Text = Tile.channelPrefix[0];
            this.channelTitle2.Text = Tile.channelPrefix[1];
            this.channelTitle3.Text = Tile.channelPrefix[2];

            setComboBoxForFICC(this.comboBox1, Tile.channel[0]);
            setComboBoxForFICC(this.comboBox2, Tile.channel[1]);
            setComboBoxForFICC(this.comboBox3, Tile.channel[2]);

            this.zedGraphControl1.GraphPane.XAxis.Scale.Min = 0;
            this.zedGraphControl1.GraphPane.XAxis.Scale.Max = this.max;
            this.zedGraphControl1.GraphPane.YAxis.Scale.Min = 0;
            this.zedGraphControl1.GraphPane.YAxis.Scale.Max = 255;
            this.zedGraphControl2.GraphPane.XAxis.Scale.Min = 0;
            this.zedGraphControl2.GraphPane.XAxis.Scale.Max = this.max;
            this.zedGraphControl2.GraphPane.YAxis.Scale.Min = 0;
            this.zedGraphControl2.GraphPane.YAxis.Scale.Max = 255;
            this.zedGraphControl3.GraphPane.XAxis.Scale.Min = 0;
            this.zedGraphControl3.GraphPane.XAxis.Scale.Max = this.max;
            this.zedGraphControl3.GraphPane.YAxis.Scale.Min = 0;
            this.zedGraphControl3.GraphPane.YAxis.Scale.Max = 255;

            this.cursor1_1.Position = Tile.scaleMin[0];
            this.cursor1_2.Position = Tile.scaleMax[0];
            this.cursor2_1.Position = Tile.scaleMin[1];
            this.cursor2_2.Position = Tile.scaleMax[1];
            this.cursor3_1.Position = Tile.scaleMin[2];
            this.cursor3_2.Position = Tile.scaleMax[2];

            this.DisplayPlot();

            this.zedGraphControl1.AxisChange();
            this.zedGraphControl2.AxisChange();
            this.zedGraphControl3.AxisChange();
        }
Пример #4
0
        private void CreateGraph(ZedGraphControl zgc)
        {
            // Get a reference to the GraphPane
            GraphPane myPane = zgc.GraphPane;

            // Set the Titles
            myPane.Title.Text       = "Intensity Histogram";
            myPane.XAxis.Title.Text = "Intensity";
            myPane.YAxis.Title.Text = "Count";

            TileView viewer = this.mosaicWindow.TileView;

            List <Tile> tiles = viewer.GetVisibleTiles();

            if (tiles == null)
            {
                return;
            }

            int[]   total_red_hist   = new int[256];
            int[]   total_green_hist = new int[256];
            int[]   total_blue_hist  = new int[256];
            ulong[] total_hist       = new ulong[256];

            int[]   red_hist    = null;
            int[]   green_hist  = null;
            int[]   blue_hist   = null;
            ulong[] hist        = null;
            bool    colourImage = false;

            if (MosaicWindow.MosaicInfo.ColorDepth >= 24)
            {
                colourImage = true;
            }

            for (int i = 0; i < total_red_hist.Length; i++)
            {
                total_red_hist[i]   = 0;
                total_green_hist[i] = 0;
                total_blue_hist[i]  = 0;
            }

            double max_posible_intensity_in_images = 0.0;

            foreach (Tile tile in tiles)
            {
                if (tile.IsDummy)
                {
                    continue;
                }

                FreeImageAlgorithmsBitmap dib = tile.LoadFreeImageBitmap();

                if (dib.MaximumPossibleIntensityValue > max_posible_intensity_in_images)
                {
                    max_posible_intensity_in_images = dib.MaximumPossibleIntensityValue;
                }

                if (colourImage)
                {
                    dib.GetHistogram(FREE_IMAGE_COLOR_CHANNEL.FICC_RED, out red_hist);
                    dib.GetHistogram(FREE_IMAGE_COLOR_CHANNEL.FICC_GREEN, out green_hist);
                    dib.GetHistogram(FREE_IMAGE_COLOR_CHANNEL.FICC_BLUE, out blue_hist);
                }
                else
                {
                    dib.GetGreyLevelHistogram(256, out hist);
                }

                dib.Dispose();

                for (int i = 0; i < total_red_hist.Length; i++)
                {
                    if (colourImage)
                    {
                        total_red_hist[i]   += red_hist[i];
                        total_green_hist[i] += green_hist[i];
                        total_blue_hist[i]  += blue_hist[i];
                    }
                    else
                    {
                        total_hist[i] += hist[i];
                    }
                }
            }

            double range_per_bin = max_posible_intensity_in_images / 256;

            double        x, y;
            PointPairList red_list   = new PointPairList();
            PointPairList green_list = new PointPairList();
            PointPairList blue_list  = new PointPairList();

            if (colourImage)
            {
                for (int i = 0; i < total_red_hist.Length; i++)
                {
                    x = (double)i;
                    y = (double)total_red_hist[i];
                    red_list.Add(x, y);

                    y = (double)total_green_hist[i];
                    green_list.Add(x, y);

                    y = (double)total_blue_hist[i];
                    blue_list.Add(x, y);
                }

                // Generate a red curve with diamond
                LineItem red_curve = myPane.AddCurve("",
                                                     red_list, Color.Red, SymbolType.None);

                LineItem green_curve = myPane.AddCurve("",
                                                       green_list, Color.Green, SymbolType.None);

                LineItem blue_curve = myPane.AddCurve("",
                                                      blue_list, Color.Blue, SymbolType.None);
            }
            else
            {
                for (int i = 0; i < total_red_hist.Length; i++)
                {
                    x = (double)(i * range_per_bin);
                    y = (double)total_hist[i];
                    red_list.Add(x, y);
                }

                // Generate a red curve with diamond
                // symbols, and "Porsche" in the legend
                BarItem curve = myPane.AddBar("",
                                              red_list, Color.Black);
            }

            zgc.AxisChange();
        }