Beispiel #1
0
        private AnalyzeAreaSet _GetCurrentAnalyzeAreaSet()
        {
            DataGridViewRow row            = dataAnalyzeAreaSets.SelectedRows[0];
            AnalyzeAreaSet  analyzeAreaSet = (AnalyzeAreaSet)row.DataBoundItem;

            return(analyzeAreaSet);
        }
        public EditAnalyzeAreaSet(Project project, int currentZ, int currentT)
        {
            this.EditMode = "Create";

            AnalyzeAreaSet analyzeAreaSet = new AnalyzeAreaSet(project.Z, project.T);

            this._Initialize(analyzeAreaSet, project, currentZ, currentT);
        }
Beispiel #3
0
        private void _SetTargetValueZ()
        {
            if (dataAnalyzeAreaSets.SelectedRows.Count > 0)
            {
                DataGridViewRow s_row            = dataAnalyzeAreaSets.CurrentRow;
                AnalyzeAreaSet  s_analyzeAreaSet = (AnalyzeAreaSet)s_row.DataBoundItem;

                //int selectZ = this._Analyzer.GetZ(s_analyzeAreaSet, scrollT.Value);

                int selectZ = 1;
                for (int z = 1; z <= this._Project.Z; z++)
                {
                    AnalyzeArea aa = s_analyzeAreaSet.GetAnalyzeArea(z, scrollT.Value);
                    if (aa.Enabled)
                    {
                        selectZ = z;
                        break;
                    }
                }

                if (scrollZ.Maximum < selectZ)
                {
                    scrollZ.Maximum = selectZ;
                }
                if (scrollZ.Minimum > selectZ)
                {
                    scrollZ.Minimum = selectZ;
                }
                if (nudZ.Maximum < selectZ)
                {
                    nudZ.Maximum = selectZ;
                }
                if (nudZ.Minimum > selectZ)
                {
                    nudZ.Minimum = selectZ;
                }

                scrollZ.Value = selectZ;
                nudZ.Value    = selectZ;

                //AnalyzeArea analyzeArea = this._GetCurrentAnalyzeArea();
                //nudThreshold.Value = analyzeArea.Threshold;

                scrollZ.Enabled = false;
                nudZ.Enabled    = false;
            }
            else
            {
                scrollZ.Enabled = true;
                nudZ.Enabled    = true;
            }
        }
Beispiel #4
0
        private void buttonRemoveAnalyzeAreaSet_Click(object sender, EventArgs e)
        {
            if (dataAnalyzeAreaSets.SelectedRows.Count > 0)
            {
                DataGridViewRow row            = dataAnalyzeAreaSets.SelectedRows[0];
                AnalyzeAreaSet  analyzeAreaSet = this._GetCurrentAnalyzeAreaSet();

                if (MessageBox.Show("解析エリア '" + analyzeAreaSet.Name + "' を削除します。\nよろしいですか?", "解析エリアの削除", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    this._IsDirty = true;
                    this._Project.RemoveAnalyzeAreaSet(row.Index);
                }
            }
        }
        public int GetZ(AnalyzeAreaSet analyzeAreaSet, int t)
        {
            int targetZ = 1;
            //AnalyzeArea analyzeArea = analyzeAreaSet.GetAnalyzeArea(1, t);
            AnalyzeArea analyzeArea = new AnalyzeArea();

            for (int z = 1; z <= this._Project.Z; z++)
            {
                analyzeArea = analyzeAreaSet.GetAnalyzeArea(z, t);

                if (analyzeArea.Enabled)
                {
                    targetZ = z;
                    break;
                }
            }

            return(targetZ);
        }
Beispiel #6
0
        private void buttonAddAnalyzeAreaSet_Click(object sender, EventArgs e)
        {
            EditAnalyzeAreaSet editAnalyzeAreaSet = new EditAnalyzeAreaSet(
                this._Project,
                scrollZ.Value,
                scrollT.Value
                );

            editAnalyzeAreaSet.ShowDialog();

            if (editAnalyzeAreaSet.CreatedAnalyzeAreaSet)
            {
                this._IsDirty = true;

                AnalyzeAreaSet analyzeAreaSet = editAnalyzeAreaSet.AnalyzeAreaSet;
                this._Project.AddAnalyzeAreaSet(analyzeAreaSet);
                this._Render();
            }

            editAnalyzeAreaSet.Dispose();
        }
        public double[] AnalyzeSpot(AnalyzeAreaSet analyzeAreaSet, int t, int threshold)
        {
            int targetZ = 0;
            //AnalyzeArea analyzeArea = analyzeAreaSet.GetAnalyzeArea(1, t);
            AnalyzeArea analyzeArea = new AnalyzeArea();

            for (int z = 1; z <= this._Project.Z; z++)
            {
                analyzeArea = analyzeAreaSet.GetAnalyzeArea(z, t);

                if (analyzeArea.Enabled)
                {
                    targetZ = z;
                    break;
                }
            }

            if (targetZ == 0)
            {
                return(new double[3]);
            }

            double[]   spots         = new double[3];
            MicroImage microImage473 = this.GetMicroImage(targetZ, t, "473");
            MicroImage microImage561 = this.GetMicroImage(targetZ, t, "561");

            //spots[0] = analyzeArea.Count473;
            //spots[1] = analyzeArea.Count561;

            spots[0] = microImage473.AnalyzeSpot(analyzeArea, threshold);
            spots[1] = microImage561.AnalyzeSpot(analyzeArea, threshold);

            //Integrated Density
            spots[2] = microImage473.AnalyzeLuminance(analyzeArea, threshold);

            return(spots);
        }
Beispiel #8
0
        private void buttonEditAnalyzeAreaSet_Click(object sender, EventArgs e)
        {
            if (dataAnalyzeAreaSets.SelectedRows.Count > 0)
            {
                AnalyzeAreaSet analyzeAreaSet = this._GetCurrentAnalyzeAreaSet();

                EditAnalyzeAreaSet editAnalyzeAreaSet = new EditAnalyzeAreaSet(
                    analyzeAreaSet,
                    this._Project,
                    scrollZ.Value,
                    scrollT.Value
                    );
                editAnalyzeAreaSet.ShowDialog();

                if (editAnalyzeAreaSet.UpdatedAnalyzeAreaSet)
                {
                    this._IsDirty = true;

                    this._Render();
                }

                editAnalyzeAreaSet.Dispose();
            }
        }
        private void _Initialize(AnalyzeAreaSet analyzeAreaSet, Project project, int currentZ, int currentT)
        {
            InitializeComponent();

            if (this.EditMode == "Create")
            {
                this.Text     = "解析エリアを追加";
                buttonOK.Text = "追加";
            }
            else
            {
                this.Text     = "解析エリアを編集";
                buttonOK.Text = "保存";
            }

            this._Project       = project;
            this.AnalyzeAreaSet = analyzeAreaSet;

            // initialize dataAnalyzeAreas
            for (int t = 1; t <= project.T; t++)
            {
                DataGridViewColumn column = new DataGridViewTextBoxColumn();
                column.Name       = t.ToString();
                column.HeaderText = "T" + t.ToString();
                column.SortMode   = DataGridViewColumnSortMode.NotSortable;

                dataAnalyzeAreas.Columns.Add(column);
            }

            DataGridViewRow row = new DataGridViewRow();

            row.HeaderCell.Value = "AREA";

            for (int t = 1; t <= project.T; t++)
            {
                DataGridViewCell cell = new DataGridViewTextBoxCell();
                cell.Value = this.AnalyzeAreaSet.GetAnalyzeArea(this._getTargetZ(t), t).ToString();
                row.Cells.Add(cell);
            }

            dataAnalyzeAreas.Rows.Add(row);

            // initialize comboC

            if (project.C >= 1)
            {
                this._Analyzer = this._Project.GetAnalyzer(1);
                this._Render();
            }

            // initialize scrolls, nuds
            scrollT.Minimum = 1;
            scrollT.Maximum = project.T;
            nudT.Minimum    = 1;
            nudT.Maximum    = project.T;

            int smaller = project.X > project.Y ? project.Y : project.X;

            nudX.Minimum         = 0;
            nudX.Maximum         = project.X - 1;
            nudY.Minimum         = 0;
            nudY.Maximum         = project.Y - 1;
            nudR.Minimum         = 1;
            nudR.Maximum         = Math.Floor((decimal)(smaller / 2));
            nudThreshold.Minimum = 0;
            nudThreshold.Maximum = 65535;


            pictureMicroImage.MouseMove       += new MouseEventHandler(pictureMicroImage_MouseMove);
            pictureMicroImage.MouseLeave      += new EventHandler(pictureMicroImage_MouseLeave);
            pictureMicroImage.MouseClick      += new MouseEventHandler(pictureMicroImage_MouseClick);
            dataAnalyzeAreas.SelectionChanged += new EventHandler(dataAnalyzeAreas_SelectionChanged);

            nudT.Value = currentT;

            dataAnalyzeAreas[currentT - 1, 0].Selected = true;

            textName.Text = analyzeAreaSet.Name;

            this._Render();
        }
        public EditAnalyzeAreaSet(AnalyzeAreaSet analyzeAreaSet, Project project, int currentZ, int currentT)
        {
            this.EditMode = "Update";

            this._Initialize(analyzeAreaSet, project, currentZ, currentT);
        }
        public bool ExportAsCSV(int index, Spot spot)
        {
            this.ClearError();

            Analyzer       analyzer       = this.GetAnalyzer(1);
            AnalyzeAreaSet analyzeAreaSet = this.GetAnalyzeAreaSet(index);

            string fileName = this.Name + "-" + analyzeAreaSet.Name + ".csv";
            string file     = "";

            SaveFileDialog dialog = new SaveFileDialog();

            dialog.FileName         = fileName;
            dialog.Filter           = "CSVファイル(*.csv)|*.csv";
            dialog.Title            = "保存先のファイルを選択してください";
            dialog.RestoreDirectory = true;

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                file = dialog.FileName;
            }
            else
            {
                this.SetError("出力を中断しました。");
                return(false);
            }

            if (File.Exists(file))
            {
                DialogResult result = MessageBox.Show(string.Format("'{0}' は既に存在します。\n新しいファイルに置き換えますか?", fileName), "CSVで出力", MessageBoxButtons.YesNo);
                if (result == DialogResult.No)
                {
                    this.SetError("出力を中断しました。");
                    return(false);
                }
            }

            try
            {
                using (StreamWriter sw = new StreamWriter(file))
                {
                    string[] times    = new string[this.T + 1];
                    string[] count473 = new string[this.T + 1];
                    string[] count561 = new string[this.T + 1];
                    string[] intDen   = new string[this.T + 1];

                    for (int t = 1; t <= this.T; t++)
                    {
                        times[t] = "T" + t.ToString();
                    }

                    this._WriteCSVLine(sw, times);

                    count473[0] = "Count473";
                    count561[0] = "Count561";
                    intDen[0]   = "IntDen";

                    int[] valueCount473 = spot._getCount473();
                    int[] valueCount561 = spot._getCount561();
                    int[] valueIntDen   = spot._getIntDen();

                    for (int t = 1; t <= this.T; t++)
                    {
                        count473[t] = valueCount473[t - 1].ToString();
                        count561[t] = valueCount561[t - 1].ToString();
                        intDen[t]   = valueIntDen[t - 1].ToString();
                    }

                    this._WriteCSVLine(sw, count473);
                    this._WriteCSVLine(sw, count561);
                    this._WriteCSVLine(sw, intDen);
                }
            }
            catch (Exception e)
            {
                this.SetError(e.Message);
                return(false);
            }


            return(true);
        }
 public void AddAnalyzeAreaSet(AnalyzeAreaSet analyzeAreaSet)
 {
     this.AnalyzeAreaSets.Add(analyzeAreaSet);
 }
Beispiel #13
0
        private void SetSpotChart()
        {
            DataGridViewRow row = dataAnalyzeAreaSets.CurrentRow;

            if (row == null)
            {
                return;
            }

            Cursor oldCursor = Cursor.Current;

            Cursor.Current   = Cursors.WaitCursor;
            labelStatus.Text = "";

            toolStripProgressBar1.Visible = true;
            toolStripProgressBar1.Maximum = this._Project.T;
            toolStripProgressBar1.Minimum = 1;

            AnalyzeAreaSet analyzeAreaSet = (AnalyzeAreaSet)row.DataBoundItem;

            chartSpot.Visible = true;
            chartSpot.Series.Clear();

            //グラフ設定
            string legend473Count = "473Count";
            string legend561Count = "561Count";
            string legendIntDen   = "IntDen";

            chartSpot.Series.Add(legend473Count);
            chartSpot.Series.Add(legend561Count);
            chartSpot.Series.Add(legendIntDen);

            chartSpot.Series[legend473Count].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
            chartSpot.Series[legend561Count].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
            chartSpot.Series[legendIntDen].ChartType   = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;

            chartSpot.Series[legend473Count].LegendText = legend473Count;
            chartSpot.Series[legend561Count].LegendText = legend561Count;
            chartSpot.Series[legendIntDen].LegendText   = legendIntDen;

            chartSpot.Series[legend473Count].IsValueShownAsLabel     = false;
            chartSpot.Series[legend473Count].SmartLabelStyle.Enabled = false;
            chartSpot.Series[legend473Count].LabelBorderDashStyle    = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.NotSet;
            chartSpot.Series[legend473Count].LabelBorderWidth        = 0;
            chartSpot.Series[legend473Count].LabelForeColor          = Color.FromArgb(0, 0, 0, 0);

            chartSpot.Series[legend561Count].IsValueShownAsLabel     = false;
            chartSpot.Series[legend561Count].SmartLabelStyle.Enabled = false;
            chartSpot.Series[legend561Count].LabelBorderDashStyle    = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.NotSet;
            chartSpot.Series[legend561Count].LabelBorderWidth        = 0;
            chartSpot.Series[legend561Count].LabelForeColor          = Color.FromArgb(0, 0, 0, 0);

            chartSpot.Series[legendIntDen].IsValueShownAsLabel     = false;
            chartSpot.Series[legendIntDen].SmartLabelStyle.Enabled = false;
            chartSpot.Series[legendIntDen].LabelBorderDashStyle    = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.NotSet;
            chartSpot.Series[legendIntDen].LabelBorderWidth        = 0;
            chartSpot.Series[legendIntDen].LabelForeColor          = Color.FromArgb(0, 0, 0, 0);

            chartSpot.Series[legendIntDen].YAxisType = System.Windows.Forms.DataVisualization.Charting.AxisType.Secondary;
            //


            string[] xValues         = new string[scrollT.Maximum];
            int[]    yValues473Count = new int[scrollT.Maximum];
            int[]    yValues561Count = new int[scrollT.Maximum];
            int[]    yValuesIntDen   = new int[scrollT.Maximum];

            for (int t = 1; t <= this._Project.T; t++)
            {
                xValues[t - 1] = t.ToString();

                double[] spots = this._Analyzer.AnalyzeSpot(analyzeAreaSet, t, (int)nudThreshold.Value);

                yValues473Count[t - 1] = (int)spots[0];
                yValues561Count[t - 1] = (int)spots[1];
                yValuesIntDen[t - 1]   = (int)spots[2];

                toolStripProgressBar1.Value = t;
                toolStripProgressBar1.PerformStep();
            }
            Spot spot = new Spot();

            spot._setCount473(yValues473Count);
            spot._setCount561(yValues561Count);
            spot._setIntDen(yValuesIntDen);
            this._Spot = spot;

            for (int i = 0; i < xValues.Length; i++)
            {
                System.Windows.Forms.DataVisualization.Charting.DataPoint dp473Count = new System.Windows.Forms.DataVisualization.Charting.DataPoint();
                System.Windows.Forms.DataVisualization.Charting.DataPoint dp561Count = new System.Windows.Forms.DataVisualization.Charting.DataPoint();
                System.Windows.Forms.DataVisualization.Charting.DataPoint dpIntDen   = new System.Windows.Forms.DataVisualization.Charting.DataPoint();

                dp473Count.SetValueXY(xValues[i], yValues473Count[i]);
                dp561Count.SetValueXY(xValues[i], yValues561Count[i]);
                dpIntDen.SetValueXY(xValues[i], yValuesIntDen[i]);

                dp473Count.IsValueShownAsLabel = true;
                dp561Count.IsValueShownAsLabel = true;
                dpIntDen.IsValueShownAsLabel   = true;

                chartSpot.Series["473Count"].Points.Add(dp473Count);
                chartSpot.Series["561Count"].Points.Add(dp561Count);
                chartSpot.Series["IntDen"].Points.Add(dpIntDen);
            }

            toolStripProgressBar1.Visible = false;
            Cursor.Current   = oldCursor;
            labelStatus.Text = "解析が完了しました";
            this._Flash      = "";

            buttonExportAsCSV.Enabled = true;
        }
Beispiel #14
0
        private AnalyzeArea _GetCurrentAnalyzeArea()
        {
            AnalyzeAreaSet analyzeAreaSet = this._GetCurrentAnalyzeAreaSet();

            return(analyzeAreaSet.GetAnalyzeArea(scrollZ.Value, scrollT.Value));
        }
Beispiel #15
0
        private void _Render()
        {
            Cursor oldCursor = Cursor.Current;

            Cursor.Current = Cursors.WaitCursor;

            if (this._Analyzer != null)
            {
                menuProjectSave.Enabled   = true;
                menuProjectSaveAs.Enabled = true;
                menuTool.Enabled          = true;

                panel.Enabled = true;

                checkDrawArea.Enabled  = dataAnalyzeAreaSets.SelectedRows.Count > 0 ? true : false;
                checkBinarize.Enabled  = dataAnalyzeAreaSets.SelectedRows.Count > 0 ? true : false;
                buttonAnalyzer.Enabled = dataAnalyzeAreaSets.SelectedRows.Count > 0 ? true : false;
                nudThreshold.Enabled   = dataAnalyzeAreaSets.SelectedRows.Count > 0 ? true : false;

                this._SetTargetValueZ();

                foreach (DataGridViewRow row in dataAnalyzeAreaSets.Rows)
                {
                    if (this._Project.T <= row.Cells.Count)
                    {
                        AnalyzeAreaSet analyzeAreaSet = (AnalyzeAreaSet)row.DataBoundItem;
                        row.HeaderCell.Value = analyzeAreaSet.Name;

                        for (int t = 1; t <= this._Project.T; t++)
                        {
                            int targetZ = 1;
                            for (int z = 1; z <= this._Project.Z; z++)
                            {
                                AnalyzeArea aa = analyzeAreaSet.GetAnalyzeArea(z, t);
                                if (aa.Enabled)
                                {
                                    targetZ = z;
                                    break;
                                }
                            }
                            row.Cells[t - 1].Value = analyzeAreaSet.GetAnalyzeArea(targetZ, t).ToString();
                        }
                    }
                }

                dataAnalyzeAreaSets.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);

                MicroImage microImage;
                if (radioButtonPic473.Checked)
                {
                    microImage = this._GetCurrentMicroImage("473");
                }
                else
                {
                    microImage = this._GetCurrentMicroImage("561");
                }

                Image image;

                if (checkBinarize.Checked == true)
                {
                    int threshold = (int)nudThreshold.Value;
                    image = microImage.GetBinarizedImage(threshold);
                }
                else
                {
                    image = microImage.GetImage();
                }

                if (checkDrawArea.Checked == true && dataAnalyzeAreaSets.SelectedRows.Count > 0)
                {
                    AnalyzeArea analyzeArea = this._GetCurrentAnalyzeArea();

                    if (analyzeArea.Enabled == true)
                    {
                        Image    tmp = new Bitmap(image.Width, image.Height);
                        Graphics g   = Graphics.FromImage(tmp);
                        g.DrawImage(image, 0, 0, image.Width, image.Height);

                        Pen pen = new Pen(Color.FromArgb(191, Color.LightGray));
                        g.DrawEllipse(
                            pen,
                            analyzeArea.X - analyzeArea.R,
                            analyzeArea.Y - analyzeArea.R,
                            analyzeArea.R * 2,
                            analyzeArea.R * 2
                            );

                        g.Dispose();

                        image = tmp;
                    }
                }

                pictureMicroImage.Image = image;
            }
            else
            {
                menuProjectSave.Enabled   = false;
                menuProjectSaveAs.Enabled = false;
                menuTool.Enabled          = false;
                chartSpot.Visible         = false;
                buttonExportAsCSV.Enabled = false;
                buttonAnalyzer.Enabled    = false;
                nudThreshold.Enabled      = false;

                panel.Enabled = false;
            }

            Cursor.Current   = oldCursor;
            labelStatus.Text = this._Flash;
            this._Flash      = "";
        }