Ejemplo n.º 1
0
        }//DrawPixelChanges

        /// <summary>
        /// Sets the reducedColumns structure, reduced the change value in each pixel
        /// to a range in between 0 and 255
        /// </summary>
        private void SetReducedColumns()
        {
            if (Columns == null)
            {
                throw new Exception("Matrix has no columns");
            }
            ReducedColumns = new List <PixelColumn>();

            double min     = MinChanged;
            double max     = MaxChanged;
            double highest = -MinChanged > MaxChanged ? -MinChanged : MaxChanged; //everything goes to positive as interested in distance from 0

            double divisor         = 255;
            double changesPerColor = highest / divisor;

            for (int i = 0; i < Columns.Count; i++)
            {
                PixelColumn col = new PixelColumn();
                col.Cells = new List <PixelCell>();

                for (int n = 0; n < Columns[i].Cells.Count; n++)
                {
                    PixelCell cell   = new PixelCell();
                    double    change = Columns[i].Cells[n].change < 0 ? -Columns[i].Cells[n].change : Columns[i].Cells[n].change;
                    cell.colour = 255 - Convert.ToInt16(change / changesPerColor);
                    col.Cells.Add(cell);
                }//height

                ReducedColumns.Add(col);
            } //width
        }     //SetReducedColumns
Ejemplo n.º 2
0
        }//DrawPixelChanges

        /// <summary>
        /// Sets the reducedColumns structure, reduced the change value in each pixel
        /// to a range in between 0 and 255
        /// </summary>
        private void SetReducedColumns()
        {
            if (Columns == null) { throw new Exception("Matrix has no columns"); }
            ReducedColumns = new List<PixelColumn>();
          
            double min = MinChanged;
            double max = MaxChanged;
            double highest = -MinChanged > MaxChanged ? -MinChanged : MaxChanged; //everything goes to positive as interested in distance from 0

            double divisor = 255;
            double changesPerColor = highest / divisor;

            for (int i = 0; i < Columns.Count; i++)
            {
                PixelColumn col = new PixelColumn();
                col.Cells = new List<PixelCell>();

                for (int n = 0; n < Columns[i].Cells.Count ; n++)
                {
                    PixelCell cell = new PixelCell();
                    double change = Columns[i].Cells[n].change < 0 ? -Columns[i].Cells[n].change : Columns[i].Cells[n].change;
                    cell.colour = 255 - Convert.ToInt16(change / changesPerColor);
                    col.Cells.Add(cell);
                }//height

                ReducedColumns.Add(col);

            }//width

        }//SetReducedColumns
Ejemplo n.º 3
0
        /// <summary>
        /// Does the actual population of the Pixel Matrix
        /// </summary>
        private void DoPopulate()
        {
            Columns    = new List <PixelColumn>();
            Comparator = null;
            if (LinkCompare)
            {
                Comparator = new List <PixelColumn>();
            }

            //set the search dimensions
            if (SearchWidth <= 0)
            {
                SearchWidth = image2.bitmap.Width;
            }
            if (SearchHeight <= 0)
            {
                SearchHeight = image2.bitmap.Height;
            }

            //set thepixel scanning dimensions
            if (WidthSearchOffset < 1)
            {
                WidthSearchOffset = 1;
            }
            if (HeightSearchOffset < 1)
            {
                HeightSearchOffset = 1;
            }

            if (GridSystemOn)
            {
                imageGrid = new ImageGrid(SearchWidth, SearchHeight);
            }

            //set some grid and comparator variables here, for scope reasons
            GridColumn  gridColumn       = null;
            Grid        grid             = null;
            PixelCell   comparatorCell   = null;
            PixelColumn comparatorColumn = null;

            //look at every pixel in each image, and compare the colours
            for (int i = 0; i < SearchWidth; i += WidthSearchOffset)
            {
                PixelColumn column = new PixelColumn();
                if (LinkCompare)
                {
                    comparatorColumn = new PixelColumn();
                }

                //set a new grid column, if required
                if (GridSystemOn)
                {
                    if (i == 0)
                    {
                        gridColumn = new GridColumn();
                    }
                    else if (i % imageGrid.GridWidth == 0)
                    {
                        imageGrid.Columns.Add(gridColumn); gridColumn = new GridColumn();
                    }
                }

                for (int n = 0; n < SearchHeight; n += HeightSearchOffset)
                {
                    PixelCell cell = new PixelCell();
                    if (LinkCompare)
                    {
                        comparatorCell = new PixelCell();
                    }

                    //set a new grid, if required
                    if (GridSystemOn)
                    {
                        if (n > 0 && n % imageGrid.GridHeight == 0 && i % imageGrid.GridWidth == 0)
                        {
                            gridColumn.grids.Add(grid);
                            grid = new Grid();
                        }
                        else if (n == 0 && i % imageGrid.GridWidth == 0)
                        {
                            grid = new Grid();
                        }
                    }

                    //get the pixel colours. image 1 pixel one either comes from image1, or the comparison PixelMatrix, if it exists
                    Int64 image1Pixel = Comparision == null?image1.bitmap.GetPixel(i, n).Name.HexToLong() : Comparision[i].Cells[n].colour;

                    Int64 image2Pixel = image2.bitmap.GetPixel(i, n).Name.HexToLong();

                    //set the comparator
                    if (LinkCompare)
                    {
                        comparatorCell.colour = image2Pixel; comparatorColumn.Cells.Add(comparatorCell);
                    }

                    if (image1Pixel != image2Pixel)
                    {
                        cell.hasChanged = true;
                        cell.change     = image1Pixel - image2Pixel;
                        if (GridSystemOn)
                        {
                            grid.change += cell.positiveChange;
                        }
                    }
                    else
                    {
                        cell.hasChanged = false;
                    }

                    column.Cells.Add(cell);

                    if (GridSystemOn && n + 1 == image1.bitmap.Height && i % imageGrid.GridWidth == 0)
                    {
                        gridColumn.grids.Add(grid);
                    }
                }//height

                Columns.Add(column);
                if (LinkCompare)
                {
                    Comparator.Add(comparatorColumn);
                }

                if (GridSystemOn && i + 1 == image1.bitmap.Width)
                {
                    imageGrid.Columns.Add(gridColumn);
                }
            }//width
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Does the actual population of the Pixel Matrix
        /// </summary>
        private void DoPopulate()
        {
            Columns = new List<PixelColumn>();
            Comparator = null;
            if (LinkCompare) { Comparator = new List<PixelColumn>(); }

            //set the search dimensions
            if (SearchWidth <= 0 ) { SearchWidth = image2.bitmap.Width; }
            if (SearchHeight <= 0 ) { SearchHeight = image2.bitmap.Height; }

            //set thepixel scanning dimensions
            if (WidthSearchOffset < 1) { WidthSearchOffset = 1; }
            if (HeightSearchOffset < 1) { HeightSearchOffset = 1; }

            if (GridSystemOn) { imageGrid = new ImageGrid(SearchWidth, SearchHeight); }

            //set some grid and comparator variables here, for scope reasons
            GridColumn gridColumn = null;
            Grid grid = null;
            PixelCell comparatorCell = null;
            PixelColumn comparatorColumn = null;

            //look at every pixel in each image, and compare the colours
            for (int i = 0; i < SearchWidth; i += WidthSearchOffset)
            {
                PixelColumn column = new PixelColumn();
                if (LinkCompare) { comparatorColumn = new PixelColumn(); }

                //set a new grid column, if required
                if (GridSystemOn)
                {
                    if (i == 0) { gridColumn = new GridColumn(); }
                    else if (i % imageGrid.GridWidth == 0) { imageGrid.Columns.Add(gridColumn); gridColumn = new GridColumn(); }
                }

                for (int n = 0; n < SearchHeight; n += HeightSearchOffset)
                {
                    PixelCell cell = new PixelCell();
                    if (LinkCompare) { comparatorCell = new PixelCell(); }

                    //set a new grid, if required              
                    if (GridSystemOn)
                    {
                        if (n > 0 && n % imageGrid.GridHeight == 0 && i % imageGrid.GridWidth == 0)
                        {
                            gridColumn.grids.Add(grid);
                            grid = new Grid();
                        }
                        else if (n == 0 && i % imageGrid.GridWidth == 0)
                        {
                            grid = new Grid();
                        }
                    }

                    //get the pixel colours. image 1 pixel one either comes from image1, or the comparison PixelMatrix, if it exists
                    Int64 image1Pixel = Comparision == null ? image1.bitmap.GetPixel(i, n).Name.HexToLong() : Comparision[i].Cells[n].colour;
                    Int64 image2Pixel = image2.bitmap.GetPixel(i, n).Name.HexToLong();

                    //set the comparator
                    if (LinkCompare) { comparatorCell.colour = image2Pixel; comparatorColumn.Cells.Add(comparatorCell); }
                    
                    if (image1Pixel != image2Pixel)
                    {
                        cell.hasChanged = true;
                        cell.change = image1Pixel - image2Pixel;
                        if (GridSystemOn) { grid.change += cell.positiveChange; }
                    }
                    else
                    {
                        cell.hasChanged = false;
                    }

                    column.Cells.Add(cell);

                    if (GridSystemOn && n + 1 == image1.bitmap.Height && i % imageGrid.GridWidth == 0) { gridColumn.grids.Add(grid); }

                }//height

                Columns.Add(column);
                if (LinkCompare) { Comparator.Add(comparatorColumn); }

                if (GridSystemOn && i + 1 == image1.bitmap.Width) { imageGrid.Columns.Add(gridColumn); }

            }//width
        }