示例#1
0
 public void DrawImage(FreeImageAlgorithmsBitmap dst, FreeImageAlgorithmsMatrix matrix,
                       int dstLeft, int dstTop, int dstWidth, int dstHeight,
                       int srcLeft, int srcTop, int srcWidth, int srcHeight,
                       RGBQUAD colour)
 {
     FreeImage.DrawImageFromSrcToDst(dst.Dib, this.Dib, matrix.Data,
                                     dstLeft, dstTop, dstWidth, dstHeight,
                                     srcLeft, srcTop, srcWidth, srcHeight,
                                     colour, 1);
 }
示例#2
0
        /*
         * public bool GetGreyLevelHistogram(int number_of_bins, out ulong[] hist, out double range_per_bin)
         * {
         *  double max = 0.0;
         *
         *  FreeImage.GetMaxPosibleValueForFib(this.Dib, out max);
         *
         *  FreeImageType type = FreeImage.GetImageType(this.Dib);
         *
         *      bool isFloat = (type == FreeImageType.Float || type == FreeImageType.Double);
         *
         *  int number_of_bins = (int) Math.Ceiling(max) + 1;
         *
         *  range_per_bin = 1.0;
         *      if(isFloat || number_of_bins > 255)
         *      {
         *              number_of_bins = 256;
         *              range_per_bin = max / 256.0;
         *      }
         *
         *  double max = this.MaximumPossibleIntensityValue;
         *  range_per_bin = max / 256.0;
         *
         *  hist = new ulong[number_of_bins];
         *
         *  return FreeImage.Histogram(this.Dib, 0, max, number_of_bins, hist);
         * }
         */

        /*
         * public bool AdjustGamma(double gamma)
         * {
         *  return FreeImage.AdjustGamma(this.Dib, gamma);
         * }
         *
         * public bool AdjustBrightness(double brightness)
         * {
         *  return FreeImage.AdjustBrightness(this.Dib, brightness);
         * }
         *
         * public bool AdjustContrast(double contrast)
         * {
         *  return FreeImage.AdjustContrast(this.Dib, contrast);
         * }
         *
         * public bool Invert()
         * {
         *  return FreeImage.Invert(this.Dib);
         * }
         *
         * public bool Paste(FreeImageBitmap src, int left, int top, int alpha)
         * {
         *  return FreeImage.Paste(this.Dib, src.dib, left, top, alpha);
         * }
         *
         * public bool Paste(FreeImageBitmap src, Point location, int alpha)
         * {
         *  return this.Paste(src, location.X, location.Y, alpha);
         * }
         */

        public new FreeImageAlgorithmsBitmap Copy(int left, int top, int right, int bottom)
        {
            EnsureNotDisposed();
            FreeImageAlgorithmsBitmap result = null;
            FIBITMAP newDib = FreeImage.Copy(this.Dib, left, top, right, bottom);

            if (!newDib.IsNull)
            {
                result = new FreeImageAlgorithmsBitmap(newDib);
            }
            return(result);
        }
示例#3
0
        public bool KernelCorrelateImageRegions(FreeImageAlgorithmsBitmap src2, Rectangle rect1, Rectangle rect2,
                                                FIARECT searchRect, FIBITMAP mask,
                                                CorrelationPrefilter prefilter, out Point pt, out double max)
        {
            FIARECT  fiaRect1 = new FIARECT(rect1);
            FIARECT  fiaRect2 = new FIARECT(rect2);
            FIAPOINT fiaPoint = new FIAPOINT();

            bool ret = FreeImage.KernelCorrelateImageRegions(this.Dib, fiaRect1, src2.Dib, fiaRect2, searchRect, mask, prefilter, out fiaPoint, out max);

            pt = new Point(fiaPoint.x, fiaPoint.y);

            return(ret);
        }
示例#4
0
        public ThumbnailMap(int thumbnailWidth, int thumbnailHeight, bool colour)
        {
            this.thumbnailWidth = thumbnailWidth;
            this.thumbnailHeight = thumbnailHeight;

            // Create Large Bitmap to hold all the thumbnals
            this.colour = colour;

            int bpp = 8;

            if(this.colour) {
                bpp = 24;
            }

            this.bmp = new FreeImageAlgorithmsBitmap(thumbnailWidth * ThumbnailMap.widthMax, thumbnailHeight * ThumbnailMap.heightMax, bpp);

            if (bpp == 8)
                this.bmp.SetGreyLevelPalette();
        }
示例#5
0
        public void PasteFromTopLeft(FreeImageAlgorithmsBitmap src, int left, int top, bool blending)
        {
            bool ret;

            if (blending)
            {
                ret = FreeImage.GradientBlendPasteFromTopLeft(this.Dib, src.Dib, left, top);
            }
            else
            {
                ret = FreeImage.PasteFromTopLeft(this.Dib, src.Dib, left, top);
            }

            if (ret == false)
            {
                string errorStr = String.Format(
                    "Can not paste freeimage. Dst image bpp {0}, Src image bpp {1}",
                    this.ColorDepth, src.ColorDepth);

                throw new FormatException(errorStr);
            }
        }
示例#6
0
        public static int guessFibMaxValue(FreeImageAlgorithmsBitmap fib)
        {
            uint bpp = FreeImage.GetBPP(fib.Dib);
            FREE_IMAGE_TYPE type = FreeImage.GetImageType(fib.Dib);
            double min, max;

            if (bpp == 8)
                return 256;

            if (bpp >= 24 && type == FREE_IMAGE_TYPE.FIT_BITMAP)  // colour image
                return 256;

            fib.FindMinMaxIntensity(out min, out max);

            if (max < 256)  // 8 bit
                return 256;
            if (max < 4096)  // 12 bit
                return 4096;
            if (max < 65536)  // 16 bit
                return 65536;

            return 100000;  // who knows!
        }
示例#7
0
 public void DrawImage(FreeImageAlgorithmsBitmap dst, Rectangle dstRect, RGBQUAD colour)
 {
     FreeImage.DrawImageToDst(dst.Dib, this.Dib, FIA_Matrix.Zero,
         dstRect.Left, dstRect.Top, dstRect.Width, dstRect.Height, colour, 1);
 }
示例#8
0
 public bool GradientBlendPasteFromTopLeft(FreeImageAlgorithmsBitmap src, Point pt)
 {
     return FreeImage.GradientBlendPasteFromTopLeft(this.Dib, src.Dib, pt.X, pt.Y);
 }
示例#9
0
        private FreeImageAlgorithmsBitmap Stitch(int stitchWidth, int stitchHeight)
        {
            float zoom = 1.0f;
            Point origin = new Point(0, 0);

            List<Tile> tiles = null;

            RoiTool roiPlugin = this.Window.GetTool("Region") as RoiTool;

            Rectangle roi = Rectangle.Empty;

            if(roiPlugin.Active == true)
                roi = roiPlugin.TransformedRegionOfInterest;

            if (roi != null && roi != Rectangle.Empty)
            {
                tiles = new List<Tile>();

                foreach (Tile tile in MosaicWindow.MosaicInfo.Items)
                {
                    if (roi.IntersectsWith(tile.Bounds))
                    {
                        tiles.Add(tile);
                    }
                }

                zoom = (float)stitchWidth / (float)(roi.Width);
                origin = roi.Location;
            }
            else
            {
                tiles = new List<Tile>(MosaicWindow.MosaicInfo.Items);
                zoom = (float)stitchWidth / (float)(MosaicWindow.MosaicInfo.TotalWidth);
            }

               // origin = Tile.GetOriginOfTiles(tiles);

            //int width = Tile.GetHorizontalRangeOfTiles(tiles);
            //int height = Tile.GetVerticalRangeOfTiles(tiles);

            int width, height;

            if (roi == Rectangle.Empty)
            {
                // Whole mosaic Width / Height
                width = MosaicWindow.MosaicInfo.TotalWidth;
                height = MosaicWindow.MosaicInfo.TotalHeight;
            }
            else
            {
                width = roi.Width;
                height = roi.Height;
            }

            FreeImageAlgorithmsBitmap section = null;

            try
            {
                section = new FreeImageAlgorithmsBitmap((int)(width * zoom), (int)(height * zoom),
                    MosaicWindow.MosaicInfo.FreeImageType, MosaicWindow.MosaicInfo.ColorDepth);
            }
            catch (FreeImageException)
            {
                return null;
            }

            FreeImageAlgorithmsBitmap tmpBitmap = null;

            int count = 1;

            foreach (Tile tile in tiles)
            {
                Point position = tile.GetTilePositionRelativeToPoint(origin);

                position.X = (int)(position.X * zoom);
                position.Y = (int)(position.Y * zoom);

                try
                {
                    tmpBitmap = tile.LoadFreeImageBitmap((int)(tile.Width * zoom), (int)(tile.Height * zoom));
                }
                catch (FreeImageException e)
                {
                    MessageBox.Show(e.Message);
                }

                section.PasteFromTopLeft(tmpBitmap, position, this.Window.BlendingEnabled);

                tmpBitmap.Dispose();

                this.threadController.ReportThreadPercentage(this, "Saving Tiles",
                    count, tiles.Count);

                count++;
            }

            return section;
        }
示例#10
0
        /*
        public bool GetGreyLevelHistogram(int number_of_bins, out ulong[] hist, out double range_per_bin)
        {
            double max = 0.0;

            FreeImage.GetMaxPosibleValueForFib(this.Dib, out max);

            FreeImageType type = FreeImage.GetImageType(this.Dib);

            bool isFloat = (type == FreeImageType.Float || type == FreeImageType.Double);

            int number_of_bins = (int) Math.Ceiling(max) + 1;

            range_per_bin = 1.0;
            if(isFloat || number_of_bins > 255)
            {
                number_of_bins = 256;
                range_per_bin = max / 256.0;
            }

            double max = this.MaximumPossibleIntensityValue;
            range_per_bin = max / 256.0;

            hist = new ulong[number_of_bins];

            return FreeImage.Histogram(this.Dib, 0, max, number_of_bins, hist);
        }
        */
        /*
        public bool AdjustGamma(double gamma)
        {
            return FreeImage.AdjustGamma(this.Dib, gamma);
        }

        public bool AdjustBrightness(double brightness)
        {
            return FreeImage.AdjustBrightness(this.Dib, brightness);
        }

        public bool AdjustContrast(double contrast)
        {
            return FreeImage.AdjustContrast(this.Dib, contrast);
        }

        public bool Invert()
        {
            return FreeImage.Invert(this.Dib);
        }

        public bool Paste(FreeImageBitmap src, int left, int top, int alpha)
        {
            return FreeImage.Paste(this.Dib, src.dib, left, top, alpha);
        }

        public bool Paste(FreeImageBitmap src, Point location, int alpha)
        {
            return this.Paste(src, location.X, location.Y, alpha);
        }
        */
        public new FreeImageAlgorithmsBitmap Copy(int left, int top, int right, int bottom)
        {
            EnsureNotDisposed();
            FreeImageAlgorithmsBitmap result = null;
            FIBITMAP newDib = FreeImage.Copy(this.Dib, left, top, right, bottom);
            if (!newDib.IsNull)
            {
                result = new FreeImageAlgorithmsBitmap(newDib);
            }
            return result;
        }
示例#11
0
        private void DrawThumbnailImage(Graphics graphics, Tile tile)
        {
            if (tile.Thumbnail != null)
            {
                lock (tile.ThumbnailLock)
                {
                    //tile.Thumbnail.ConvertToStandardType();
                    FreeImageAlgorithmsBitmap thumb = new FreeImageAlgorithmsBitmap(tile.Thumbnail);

                    if (thumb.IsGreyScale)
                    {
                        thumb.LinearScaleToStandardType(
                            mosaicInfo.ThumbnailScaleMinIntensity, mosaicInfo.ThumbnailScaleMaxIntensity);
                        thumb.SetGreyLevelPalette();
                    }

                    if (thumb.ImageType != FREE_IMAGE_TYPE.FIT_BITMAP)
                    {
                        MessageBox.Show("Failed to convert tile thumbnail to a standard type ?");
                    }

                    graphics.DrawImage(thumb.ToBitmap(), tile.Bounds);

                    thumb.Dispose();
                }
            }

            /*
            if (this.ShowFileNames)
            {
                // Create font and brush.
                Font drawFont = new Font("Arial", 16);
                SolidBrush drawBrush = new SolidBrush(Color.Black);

                Point location = new Point(tile.Bounds.Location.X + 100, tile.Bounds.Location.Y + 100);

                SizeF size = graphics.MeasureString(tile.FileName, drawFont);

                Brush brush = new SolidBrush(Color.FromArgb(50, Color.Gray));

                graphics.FillRectangle(brush, location.X - 2, location.Y - 2,
                    size.Width + 4, size.Height + 4);

                graphics.DrawString(tile.FileName, drawFont, drawBrush,
                    new PointF(location.X, location.Y));
            }
            */

            if (this.ShowJoins)
            {
                Pen pen = new Pen(Color.Red, 2.0f);
                graphics.DrawRectangle(pen, tile.Bounds);
            }
        }
示例#12
0
        private void OnTileCorrelationBegin(CorrelationTile tile, FreeImageAlgorithmsBitmap fib)
        {
            this.useCorrelationCheckBox.Checked = false;
            this.currentTile = tile;

            #if DEBUG

            FreeImageAlgorithmsBitmap fg = new FreeImageAlgorithmsBitmap(fib);

            fg.ConvertToStandardType(true);
            fg.ConvertTo24Bits();

            this.debugForm.TileImageView.Image = fg.ToBitmap();

            this.debugForm.BackgroundImageView.Refresh();
            this.debugForm.TileImageView.Refresh();

            fg.Dispose();

            #endif
        }
示例#13
0
        public void Initialise(MosaicInfo info, Rectangle virtualArea, Size imageSize, bool forceGreyscale)
        {
            this.info = info;
            this.virtualArea = virtualArea;
            this.forceGreyscale = forceGreyscale;

            float aspectRatio = (float)(virtualArea.Width) / virtualArea.Height;

            if (imageSize.Width < imageSize.Height)
            {
                imageSize.Width = (int)(imageSize.Height * aspectRatio + 0.5);
            }
            else
            {
                imageSize.Height = (int)(imageSize.Width / aspectRatio + 0.5);
            }

            if (this.info != null)
            {
                xScaleFactor = (float)imageSize.Width / virtualArea.Width;
                yScaleFactor = (float)imageSize.Height / virtualArea.Height;

                // Set the view zoom factor so the large background image is fit to window
                // by default.
                float factor = Math.Min((float)this.Width / imageSize.Width,
                                        (float)this.Height / imageSize.Height);
                this.Zoom = factor;
            }

            if (this.forceGreyscale || info.IsGreyScale)
                this.image = new FreeImageAlgorithmsBitmap(imageSize.Width, imageSize.Height, 8);
            else
                this.image = new FreeImageAlgorithmsBitmap(imageSize.Width, imageSize.Height, 24);
        }
示例#14
0
 private void DestroyIntermediateBitmap()
 {
     if (this.intermediateBitmap != null)
     {
         this.intermediateBitmap.Dispose();
         this.intermediateBitmap = null;
         this.intermediateBitmapDrawn = false;
     }
 }
示例#15
0
        protected void SendTileCorrelatationBegin(CorrelationTile tile, FreeImageAlgorithmsBitmap fib)
        {
            if (this.ThreadController.ThreadAborted)
                return;

            Object[] objects = { tile, fib };

            this.threadController.InvokeObject.BeginInvoke(this.TileCorrelationBeginHandler, objects);
        }
示例#16
0
 public void PasteFromTopLeft(FreeImageAlgorithmsBitmap src, Point location, bool blending)
 {
     this.PasteFromTopLeft(src, location.X, location.Y, blending);
 }
示例#17
0
 public bool GradientBlendPasteFromTopLeft(FreeImageAlgorithmsBitmap src, int left, int top)
 {
     return(FreeImage.GradientBlendPasteFromTopLeft(this.Dib, src.Dib, left, top));
 }
示例#18
0
 public bool GradientBlendPasteFromTopLeft(FreeImageAlgorithmsBitmap src, Point pt)
 {
     return(FreeImage.GradientBlendPasteFromTopLeft(this.Dib, src.Dib, pt.X, pt.Y));
 }
示例#19
0
        protected void SendTileCorrelated(CorrelationTile tile, Rectangle correlatedBounds, FreeImageAlgorithmsBitmap fib, bool success)
        {
            if (this.ThreadController.ThreadAborted)
                return;

            Object[] objects = { tile, correlatedBounds, fib, success};

            this.threadController.InvokeObject.BeginInvoke(this.TileCorrelatedHandler, objects);
        }
示例#20
0
 public FreeImageAlgorithmsBitmap(FreeImageAlgorithmsBitmap fib) : base(fib)
 {
 }
示例#21
0
 public void DrawImage(FreeImageAlgorithmsBitmap dst, Rectangle dstRect, RGBQUAD colour)
 {
     FreeImage.DrawImageToDst(dst.Dib, this.Dib, FIA_Matrix.Zero,
                              dstRect.Left, dstRect.Top, dstRect.Width, dstRect.Height, colour, 1);
 }
示例#22
0
 public void AddTile(Tile tile, FreeImageAlgorithmsBitmap fib)
 {
     AddTile(tile.Bounds, fib);
 }
示例#23
0
 public void DrawImage(FreeImageAlgorithmsBitmap dst, Point dstPoint, Size dstSize, RGBQUAD colour)
 {
     FreeImage.DrawImageToDst(dst.Dib, this.Dib, FIA_Matrix.Zero,
                              dstPoint.X, dstPoint.Y, dstSize.Width, dstSize.Height, colour, 1);
 }
示例#24
0
        private void DrawIntermediateBitmap()
        {
            if (!this.intermediateBitmapDrawn)
            {
                this.threadController.ReportThreadStarted(this, "Started Zoom");

                float aspectRatio = (float)(this.mosaicInfo.TotalWidth) / this.mosaicInfo.TotalHeight;

                int scaledWidth = Screen.PrimaryScreen.Bounds.Size.Width;
                int scaledHeight = (int)(scaledWidth / aspectRatio + 0.5);

                if (this.mosaicInfo.IsGreyScale)
                {
                    this.intermediateBitmap = new FreeImageAlgorithmsBitmap(scaledWidth, scaledHeight, 8);
                }
                else
                {
                    this.intermediateBitmap = new FreeImageAlgorithmsBitmap(scaledWidth, scaledHeight, 24);
                }

                float xscaleFactor = (float)scaledWidth / this.mosaicInfo.TotalWidth;
                float yscaleFactor = (float)scaledHeight / this.mosaicInfo.TotalHeight;

                if (this.intermediateBitmap == null)
                {
                    MessageBox.Show("Failed to create intermediate bitmap");
                }

                float scale = (float)scaledWidth / this.mosaicInfo.TotalWidth;

                Point scaledPosition = new Point();

                int count = 0;

                foreach (Tile tile in this.mosaicInfo.Items)
                {
                    if (tile.Thumbnail == null)
                        MessageBox.Show("Error thumnail is null");

                    //FreeImageAlgorithmsBitmap thumb = null;

                    //lock (tile.ThumbnailLock)
                    //{
                    //    thumb = new FreeImageAlgorithmsBitmap(tile.Thumbnail);
                    //}

                    FreeImageAlgorithmsBitmap fib = tile.LoadFreeImageBitmap();

                    fib.Rescale(new Size((int)(xscaleFactor * fib.Width), (int)(yscaleFactor * fib.Height)), FREE_IMAGE_FILTER.FILTER_BILINEAR);

                    if (fib.IsGreyScale)
                    {
                        fib.LinearScaleToStandardType(mosaicInfo.ScaleMinIntensity, mosaicInfo.ScaleMaxIntensity);

                        fib.SetGreyLevelPalette();
                    }
                    else
                    {
                        fib.ConvertToStandardType(true);
                    }

                    if (fib.ImageType != FREE_IMAGE_TYPE.FIT_BITMAP)
                    {
                        MessageBox.Show("Failed to convert tile thumbnail to a standard type ?");
                    }

                    Size scaledSize = new Size((int)(tile.Width * xscaleFactor + 0.5),
                                               (int)(tile.Height * yscaleFactor + 0.5));

                    scaledPosition.X = (int)(tile.Position.X * xscaleFactor + 0.5);
                    scaledPosition.Y = (int)(tile.Position.Y * yscaleFactor + 0.5);

                    Rectangle dstRect = new Rectangle(scaledPosition, scaledSize);

                    intermediateBitmap.PasteFromTopLeft(fib, scaledPosition, this.BlendingEnabled);

                    fib.Dispose();

                    this.threadController.ReportThreadPercentage(this,
                        "Performing Zoom", count++, this.tiles.Count);
                }
            }

            //intermediateBitmap.ConvertTo24Bits();

            this.intermediateBitmapDrawn = true;
            this.preventIdleProcessing = false;
            this.dontDraw = false;

            this.threadController.ReportThreadCompleted(this, "Zoom Completed", false);

            this.Redraw();
            this.Invalidate();
        }
示例#25
0
 public bool KernelCorrelateImageRegions(FreeImageAlgorithmsBitmap src2, FIARECT rect1, FIARECT rect2,
                                         FIBITMAP mask,
                                         CorrelationPrefilter prefilter, out FIAPOINT pt, out double max)
 {
     return(FreeImage.KernelCorrelateImageRegions(this.Dib, rect1, src2.Dib, rect2, FIARECT.Empty, mask, prefilter, out pt, out max));
 }
示例#26
0
        private void OnTileCorrelated(CorrelationTile tile, Rectangle bounds, FreeImageAlgorithmsBitmap fib, bool success)
        {
            this.tiledImageViewer.AddTile(bounds, fib);

            this.tiledImageViewer.Refresh();

            #if DEBUG
            if (success == false)
            {
                FreeImageAlgorithmsBitmap bg = new FreeImageAlgorithmsBitmap(this.correlator.BackgroundImage);
                bg.ConvertTo24Bits();
                bg.DrawColourRect(tile.OriginalBoundsRelativeToOrigin, Color.Red, 2);
                this.debugForm.BackgroundImageView.Image = bg.ToBitmap();
                bg.Dispose();
            }

            this.debugForm.Refresh();
            #endif
        }
示例#27
0
 public bool KernelCorrelateImageRegions(FreeImageAlgorithmsBitmap src2, FIARECT rect1, FIARECT rect2,
                                         out FIAPOINT pt, out double max)
 {
     return(FreeImage.KernelCorrelateImageRegions(this.Dib, rect1, src2.Dib, rect2, FIARECT.Empty, FIBITMAP.Zero, null, out pt, out max));
 }
        public double Correlate(FreeImageAlgorithmsBitmap backgroundImage, FreeImageAlgorithmsBitmap fib,
            CorrelationTile tile1, CorrelationTile tile2,
            bool randomise, out Point pt)
        {
            this.backgroundIntersectArea = Rectangle.Empty;
            this.searchArea = Rectangle.Empty;
            this.searchAreaWithinMosaic = Rectangle.Empty;

            double measure = 0.0;
            pt = new Point();

            // Find the intersection between the tile and the background drawn bounds.
            this.backgroundIntersectArea = Rectangle.Intersect(tile1.CorrelatedBoundsRelativeToOrigin, tile2.CorrelatedBoundsRelativeToOrigin);

            if (this.backgroundIntersectArea == Rectangle.Empty)
            {
                SendFeedback(String.Format("{0} and {1} did not intersect ?", tile1.Tile.FileName, tile2.Tile.FileName)
                    + Environment.NewLine, Color.Red);

                return 0.0;
            }

            // determine the area over which to perform the correlation
            // defines the maximum shift allowed of the new tile.
            this.searchArea = this.SearchBounds(this.backgroundIntersectArea, randomise);

            // find the kernel area in the bg image
            this.kernelAreaWithinBackground = this.KernelBounds(this.backgroundIntersectArea, this.searchArea, randomise);

            // locate the area in the new image
            this.kernelArea = this.kernelAreaWithinBackground;

            this.kernelArea.X -= tile1.CorrelatedBoundsRelativeToOrigin.X;
            this.kernelArea.Y -= tile1.CorrelatedBoundsRelativeToOrigin.Y;

            // Call start correlation delegate, for screen update
            this.SendTileCorrelatationBegin(tile1, fib);

            if (KernalBasedOverlapCorrelator.prefilter == null)
            {
                backgroundImage.KernelCorrelateImageRegions(fib, backgroundIntersectArea, kernelArea,
                    this.searchArea, out pt, out measure);
            }
            else
            {
                backgroundImage.KernelCorrelateImageRegions(fib, backgroundIntersectArea, kernelArea, this.searchArea,
                    KernalBasedOverlapCorrelator.prefilter, out pt, out measure);
            }

            if (measure > KernalBasedOverlapCorrelator.GoodCorrelation)
            {
                pt = CorrelationTile.TranslateBackgroundPointToMosaicPoint(pt);

                return measure;
            }

            if (tile1.NumberOfAtemptedCorrelations < CorrelationTile.MaxNumberOfCorrelationAttempts)
            {
                tile1.NumberOfAtemptedCorrelations++;

                return this.Correlate(backgroundImage, fib, tile1, tile2,
                    this.knownOverlapCorrelatorOptionPanel.RandomKernelSearch, out pt);
            }
            else
            {
                // If we are debugging lets pause the thread for closer inspection
                #if DEBUG
                this.CorrelationPause();
                #endif
            }

            return measure;
        }
示例#29
0
 public bool KernelCorrelateImageRegions(FreeImageAlgorithmsBitmap src2, FIARECT rect1, FIARECT rect2,
     FIBITMAP mask,
     CorrelationPrefilter prefilter, out FIAPOINT pt, out double max)
 {
     return FreeImage.KernelCorrelateImageRegions(this.Dib, rect1, src2.Dib, rect2, FIARECT.Empty, mask, prefilter, out pt, out max);
 }
示例#30
0
 public FreeImageAlgorithmsBitmap(FreeImageAlgorithmsBitmap fib)
     : base(fib)
 {
 }
示例#31
0
        public bool KernelCorrelateImageRegions(FreeImageAlgorithmsBitmap src2, Rectangle rect1, Rectangle rect2,
            FIARECT searchRect, FIBITMAP mask,
            CorrelationPrefilter prefilter, out Point pt, out double max)
        {
            FIARECT fiaRect1 = new FIARECT(rect1);
            FIARECT fiaRect2 = new FIARECT(rect2);
            FIAPOINT fiaPoint = new FIAPOINT();

            bool ret = FreeImage.KernelCorrelateImageRegions(this.Dib, fiaRect1, src2.Dib, fiaRect2, searchRect, mask, prefilter, out fiaPoint, out max);

            pt = new Point(fiaPoint.x, fiaPoint.y);

            return ret;
        }
示例#32
0
 public void DrawImage(FreeImageAlgorithmsBitmap dst, FreeImageAlgorithmsMatrix matrix,
     int dstLeft, int dstTop, int dstWidth, int dstHeight, RGBQUAD colour)
 {
     FreeImage.DrawImageToDst(dst.Dib, this.Dib, matrix.Data,
         dstLeft, dstTop, dstWidth, dstHeight, colour, 1);
 }
示例#33
0
 public bool KernelCorrelateImageRegions(FreeImageAlgorithmsBitmap src2, Rectangle rect1, Rectangle rect2,
     FIBITMAP mask,
     CorrelationPrefilter prefilter, out Point pt, out double max)
 {
     return this.KernelCorrelateImageRegions(src2, rect1, rect2, FIARECT.Empty, mask, prefilter, out pt, out max);
 }
示例#34
0
 public void DrawImage(FreeImageAlgorithmsBitmap dst, Point dstPoint, Size dstSize, RGBQUAD colour)
 {
     FreeImage.DrawImageToDst(dst.Dib, this.Dib, FIA_Matrix.Zero,
         dstPoint.X, dstPoint.Y, dstSize.Width, dstSize.Height, colour, 1);
 }
示例#35
0
        public void PasteFromTopLeft(FreeImageAlgorithmsBitmap src, int left, int top, bool blending)
        {
            bool ret;

            if(blending) {
                ret = FreeImage.GradientBlendPasteFromTopLeft(this.Dib, src.Dib, left, top);
            }
            else {
                ret = FreeImage.PasteFromTopLeft(this.Dib, src.Dib, left, top);
            }

            if (ret == false)
            {
                string errorStr = String.Format(
                        "Can not paste freeimage. Dst image bpp {0}, Src image bpp {1}",
                        this.ColorDepth, src.ColorDepth);

                    throw new FormatException(errorStr);
            }
        }
示例#36
0
 public bool GradientBlendPasteFromTopLeft(FreeImageAlgorithmsBitmap src, int left, int top)
 {
     return FreeImage.GradientBlendPasteFromTopLeft(this.Dib, src.Dib, left, top);
 }
示例#37
0
        private void CreateBackgroundImage()
        {
            // All tiles are assumed to be the same size.
            Tile tile = this.MosaicInfo.Items[0];

            int width = tile.Width * 3;
            int height = tile.Height * 3;

            // Create a full res scratch image
            // This should be 3x3 images in size and should never need to be larger as
            // it is only used for correlation a small region of the tiles at a time.
             //           if (this.MosaicInfo.IsGreyScale)
                this.backgroundImage = new FreeImageAlgorithmsBitmap(width, height, 8);
             //           else
             //               this.backgroundImage = new FreeImageAlgorithmsBitmap(width, height, 24);
        }
示例#38
0
 public bool KernelCorrelateImageRegions(FreeImageAlgorithmsBitmap src2, FIARECT rect1, FIARECT rect2,
     out FIAPOINT pt, out double max)
 {
     return FreeImage.KernelCorrelateImageRegions(this.Dib, rect1, src2.Dib, rect2, FIARECT.Empty, FIBITMAP.Zero, null, out pt, out max);
 }
示例#39
0
 public bool KernelCorrelateImageRegions(FreeImageAlgorithmsBitmap src2, Rectangle rect1, Rectangle rect2,
                                         Rectangle search_area,
                                         CorrelationPrefilter prefilter, out Point pt, out double max)
 {
     return(this.KernelCorrelateImageRegions(src2, rect1, rect2, search_area, FIBITMAP.Zero, prefilter, out pt, out max));
 }
示例#40
0
 public bool KernelCorrelateImageRegions(FreeImageAlgorithmsBitmap src2, Rectangle rect1, Rectangle rect2,
     Rectangle search_area,
     CorrelationPrefilter prefilter, out Point pt, out double max)
 {
     return this.KernelCorrelateImageRegions(src2, rect1, rect2, search_area, FIBITMAP.Zero, prefilter, out pt, out max);
 }
示例#41
0
 public bool KernelCorrelateImageRegions(FreeImageAlgorithmsBitmap src2, Rectangle rect1, Rectangle rect2,
                                         FIBITMAP mask,
                                         CorrelationPrefilter prefilter, out Point pt, out double max)
 {
     return(this.KernelCorrelateImageRegions(src2, rect1, rect2, FIARECT.Empty, mask, prefilter, out pt, out max));
 }
示例#42
0
 public bool KernelCorrelateImageRegions(FreeImageAlgorithmsBitmap src2, Rectangle rect1, Rectangle rect2,
     out Point pt, out double max)
 {
     return this.KernelCorrelateImageRegions(src2, rect1, rect2,
         FIARECT.Empty, FIBITMAP.Zero, null, out pt, out max);
 }
示例#43
0
 public bool KernelCorrelateImageRegions(FreeImageAlgorithmsBitmap src2, Rectangle rect1, Rectangle rect2,
                                         out Point pt, out double max)
 {
     return(this.KernelCorrelateImageRegions(src2, rect1, rect2,
                                             FIARECT.Empty, FIBITMAP.Zero, null, out pt, out max));
 }
示例#44
0
 public void PasteFromTopLeft(FreeImageAlgorithmsBitmap src, Point location, bool blending)
 {
     this.PasteFromTopLeft(src, location.X, location.Y, blending);
 }
示例#45
0
        private void CreateHighResBitmap()
        {
            if (this.ClientRectangle.Width == 0 || this.ClientRectangle.Height == 0)
                return;

            if (this.highResBitmap != null)
            {
                if (this.highResBitmap.Width == this.ClientRectangle.Width &&
                    this.highResBitmap.Height == this.ClientRectangle.Height)
                {
                    this.highResBitmap.Clear();
                    return;
                }
            }

            this.highResBitmap =
                new FreeImageAlgorithmsBitmap(this.ClientRectangle.Width, this.ClientRectangle.Height, 24);
        }