Example #1
0
    private bool OnAllSpritesCompleteEvent(object obj, int p1, int p2)
    {
        foreach (var sp in spriteDic.Values)
        {
            if (!sp.complete)
            {
                return(true);
            }
        }
        List <CImage> images = obj as List <CImage>;

        for (int i = 0; i < images.Count; ++i)
        {
            CImage image = images[i];
            if (spriteDic.ContainsKey(image.AtlasName))
            {
                CSimpleSpriteObject Spriteobj = spriteDic[image.AtlasName];
                image.sprite = Spriteobj.GetSPInstance().GetSprite(image.SpriteName);
            }
        }
        if (mCachedCallback != null)
        {
            mCachedCallback(this);
            mCachedCallback = null;
        }
        return(false);
    }
 private void Bind()
 {
     if (DTSettings.Rows.Count > 0)
     {
         TxtRHdr1.Text    = DTSettings.Rows[0]["RHdr1"].ToString();
         TxtRHdr2.Text    = DTSettings.Rows[0]["RHdr2"].ToString();
         TxtRHdr3.Text    = DTSettings.Rows[0]["RHdr3"].ToString();
         TxtLHdr1.Text    = DTSettings.Rows[0]["LHdr1"].ToString();
         TxtLHdr2.Text    = DTSettings.Rows[0]["LHdr2"].ToString();
         TxtLHdr3.Text    = DTSettings.Rows[0]["LHdr3"].ToString();
         TxtFooter.Text   = DTSettings.Rows[0]["Footer"].ToString();
         PictureHdr.Image = CImage.ArrayTextToImage(DTSettings.Rows[0]["PictureHdr"]);
     }
     else
     {
         TxtRHdr1.Text    = "";
         TxtRHdr2.Text    = "";
         TxtRHdr3.Text    = "";
         TxtLHdr1.Text    = "";
         TxtLHdr2.Text    = "";
         TxtLHdr3.Text    = "";
         TxtFooter.Text   = "";
         PictureHdr.Image = null;
     }
 }
        public ActionResult BackEditTheRoomDetail(CImage r)
        {
            Room room = dbSA.Room.Where(t => t.ID == r.roomID).FirstOrDefault();



            if (room != null)
            {
                int    index     = r.mypic.FileName.IndexOf(".");
                string extention = r.mypic.FileName.Substring(index, r.mypic.FileName.Length - index);
                string photoName = Guid.NewGuid().ToString() + extention;
                r.entity_room = room;
                r.entity_room.Picture.FirstOrDefault().RoomStylePicture = "/Content/" + photoName;
                r.mypic.SaveAs(Server.MapPath("/Content/") + photoName);

                room.RoomName = r.roomname;
                room.RoomType = r.roomtype;

                //room.BuildCase.BuildCaseName = r.BuildCase.BuildCaseName;
                room.Description   = r.description;
                room.SquareFootage = r.squarefootage;
                room.Rent          = r.rent;

                Picture picture = new Picture();
                picture.RoomStylePicture = r.entity_room.Picture.FirstOrDefault().RoomStylePicture;
                picture.RoomID           = r.roomID;

                dbSA.SaveChanges();
            }
            return(RedirectToAction("BackRoomManage"));
        }
Example #4
0
        public static CImage<double> GetBackground(int height, int width, double alfa, double Df, double Mf)
        {
            CImage<Complex> BackgroundImg = Background.GenareteACF(height, width, alfa, Df).ToComplex();
              var fBgImg = FourierTransform.ForwardFFT2D(BackgroundImg);
              CImage<Complex> NoiseImg = Background.GenarateNoise(height, width, 1).ToComplex();
              var fNImg = FourierTransform.ForwardFFT2D(NoiseImg);
              CImage<Complex> img = new CImage<Complex>(height, width);
              CImage<Complex> sqrt = new CImage<Complex>(height, width);

              for (int i = 0; i < height; i++)
              {
            for (int j = 0; j < width; j++)
            {
              sqrt[i, j] = fBgImg[i, j].Sqrt;
              //img[i, j] = new Complex(Math.Sqrt(Math.Abs(fBgImg[i, j].Re)), 0) * fNImg[i, j];
              img[i, j] = sqrt[i, j] * fNImg[i, j];
            }
              }
              var res = FourierTransform.BackwardFFT2D(img).ToDouble();

              for (int i = 0; i < height; i++)
              {
            for (int j = 0; j < width; j++)
            {
              res[i, j] = res[i, j] + Mf;
            }
              }

              return res;
        }
Example #5
0
    protected void LoadAsset(GameObject go)
    {
        CText[] texts = go.GetComponentsInChildren <CText>(true);
        for (int i = 0; i < texts.Length; ++i)
        {
            CText t = texts[i];
            if (t.FontName == Global.uifont.name)
            {
                t.font = Global.uifont;
            }
            else
            {
                t.font = Global.uifont_title;
            }
        }

        List <CImage> imagelist = new List <CImage>();

        CImage[] images = go.GetComponentsInChildren <CImage>(true);
        for (int i = 0; i < images.Length; ++i)
        {
            CImage ci = images[i];
            if (string.IsNullOrEmpty(ci.AtlasName))
            {
                continue;
            }
            imagelist.Add(ci);
            CreateSPInstance(ci.AtlasName);
        }
        AddTimer(OnAllSpritesCompleteEvent, imagelist, 0, 0);
    }
        public static CImage FourPointStraighten(CImage image, Point[] newCornerPoints, IProgress <int> progressReporter = null)
        {
            if (image == null)
            {
                throw new ArgumentNullException();
            }

            if (newCornerPoints == null)
            {
                throw new ArgumentNullException();
            }

            if (newCornerPoints.Length < 4)
            {
                throw new ArgumentException();
            }

            Utilities.SetProgress(progressReporter, 0);

            image = Rect_Optimal(newCornerPoints, image, progressReporter);

            Utilities.SetProgress(progressReporter, 100);

            return(image);
        }
        public void Show(string message, bool isError)
        {
            if (string.IsNullOrEmpty(message))
            {
                Hide();
                return;
            }

            ImageIcon       = isError ? ActiveQueryBuilder.View.WPF.Images.Common.Exclamation.Value : ActiveQueryBuilder.View.WPF.Images.Common.AlertExclamation.Value;
            BoxMessage.Text = message;

            if (isError)
            {
                var link = new Hyperlink(
                    new Run(Helpers.Localizer.GetString("StrFixIssue", Helpers.ConvertLanguageFromNative(Language), LocalizableConstantsUI.strFixIssue)));

                link.Click += delegate
                {
                    OnFixIssue();
                };

                BoxMessage.Inlines.Add(" ");
                BoxMessage.Inlines.Add(link);
            }

            Visibility = Visibility.Visible;
        }
Example #8
0
        private void ButtonOpenVideo_Click(object sender, EventArgs e)
        {
            string video_file = FileSystem.OpenVideoFile();

            if (video_file.Length == 0)
            {
                return;
            }

            m_cVideoFrame = new CImage();
            m_cFrameShow  = new CImage();

            IntPtr strPtr = Marshal.StringToHGlobalAnsi(video_file);

            error_code = SDK.LoadVideo(strPtr, video_file.Length, ref hVideoHandle, ref m_cVideoFrame);
            if (error_code != ErrorCode.SYY_NO_ERROR)
            {
                MessageBox.Show("加载视频出错.");
                return;
            }

            m_cVideoFrame.pData = Marshal.AllocHGlobal(m_cVideoFrame.nHeight * m_cVideoFrame.nWidth * m_cVideoFrame.nChannels);

            m_cFrameShow       = m_cVideoFrame;
            m_cFrameShow.pData = Marshal.AllocHGlobal(m_cVideoFrame.nHeight * m_cVideoFrame.nWidth * m_cVideoFrame.nChannels);
        }
Example #9
0
        private void button7_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.InitialDirectory = "C://";
            openFileDialog.Filter           = "AVI|*.avi|其他视频格式|*.*";
            openFileDialog.RestoreDirectory = true;
            openFileDialog.FilterIndex      = 1;
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                m_sVideoFile = openFileDialog.FileName;

                m_videoFrame = new CImage();
                IntPtr strPtr = Marshal.StringToHGlobalAnsi(m_sVideoFile);

                error_code = SDK.LoadVideo(strPtr, m_sVideoFile.Length, ref hVideoHandle, ref m_videoFrame);
                if (error_code != ErrorCode.SYY_NO_ERROR)
                {
                    MessageBox.Show("加载视频出错.");
                    return;
                }

                m_videoFrame.pData = Marshal.AllocHGlobal(m_videoFrame.nHeight * m_videoFrame.nWidth * m_videoFrame.nChannels);

                m_videoCaptureThread = new Thread(new ThreadStart(CaptureVideoThread));
                m_videoCaptureThread.Start();
                //CaptureVideoThread();
            }
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Stopwatch a = new Stopwatch();

            var bmp = new BitmapImage(new Uri("D://lena.jpg"));

            imgSource.Source = bmp;

            a.Start();
            int stride = bmp.Format.BitsPerPixel / 8 * bmp.PixelWidth;

            var pixels = new byte[stride * bmp.PixelHeight];

            bmp.CopyPixels(pixels, stride, 0);

            CImage cImage = new CImage(bmp.PixelWidth, bmp.PixelHeight, bmp.Format.BitsPerPixel, pixels);

            WriteableBitmap writeableBitmap = new WriteableBitmap(bmp.PixelWidth, bmp.PixelHeight, bmp.DpiX, bmp.DpiY, bmp.Format, null);

            writeableBitmap.WritePixels(new Int32Rect(0, 0, bmp.PixelWidth, bmp.PixelHeight), cImage.Grid, stride, 0);

            a.Stop();

            imgResult.Source = writeableBitmap;

            lblTime.Content = a.ElapsedMilliseconds + "ms";
        }
Example #11
0
        public byte[] GetImageData(int userImgId)
        {
            CImage image = new CImage();

            image.LoadData(userImgId);
            return(image.Content);
        }
Example #12
0
        public TitleScene(GraphicsDevice graphicsDevice,
                          IContentProvider content,
                          IMouseEvents mouse,
                          IGameStateFactory gameStateFactory,
                          CImage img,
                          CSound snd,
                          WorldCollection worlds,
                          HighscoreCollection highscores,
                          BBXConfig config)
        {
            this.graphicsDevice   = graphicsDevice;
            this.content          = content;
            this.gameStateFactory = gameStateFactory;
            this.img         = img;
            this.snd         = snd;
            this.config      = config;
            this.spriteBatch = new SpriteBatch(graphicsDevice);

            this.random = new Random();

            this.worlds     = worlds;
            this.highscores = highscores;
            this.worlds.LoadWorlds(content);

            this.mouse = mouse;

            mouse.MouseMove += Mouse_MouseMove;
            mouse.MouseUp   += Mouse_MouseUp;

            keyboard          = new KeyboardEvents();
            keyboard.KeyDown += Keyboard_KeyDown;
            font              = new Font(img.Fonts.Default);
        }
Example #13
0
        private void ButtonAnalysisImage_Click(object sender, EventArgs e)
        {
            CImage image = new CImage();

            if (false == SDK.CvtBitmap2CImage(m_Bitmap, ref image))
            {
                MessageBox.Show("CvtBitmap2CImage出错!");
                return;
            }

            BUAnalysisResult result = new BUAnalysisResult();

            error_code = SDK.ExecuteBUAnalysisFromImage(hAnalysisHandle, image, ref result);
            if (error_code != ErrorCode.SYY_NO_ERROR)
            {
                MessageBox.Show("运行分析出错,请查看log文件。");
                return;
            }

            error_code = SDK.DrawResult2Image(ref image, result);
            if (error_code != ErrorCode.SYY_NO_ERROR)
            {
                MessageBox.Show("运行转换出错,请查看log文件。");
                return;
            }


            ShowImage(image);
        }
Example #14
0
        static void Main(string[] args)
        {
            Func<int, double> func = i => (i > 1 && i < 6) ? 1 : 0;
              var image = new CImage<double>(8, 8);

              //написать по крутому пока пишем по ламерски

              for (int i = 0; i < 8; i++)
              {
            for (int j = 0; j < 8; j++)
            {
              image[i, j] = func(i) * func(j);
            }
              }

              var res1 = FourierTransform.ForwardFFT2D(image.ToComplex());
              var res = FourierTransform.BackwardFFT2D(res1);

              for (int i = 0; i < 8; i++)
              {
            for (int j = 0; j < 8; j++)
            {
              Console.Write("{0} ", res[i, j]);
            }
            Console.WriteLine();
              }

              var c1 = new Complex(-123, 456);
              var c2 = c1.Sqrt;
              Console.WriteLine(c2*c2);
        }
        public static CImage ConvertYIQToRGB(CImage yiqImg)
        {
            CImage rgbImg = new CImage(yiqImg.Width, yiqImg.Height, yiqImg.nBytes);
            var    rFunc  = YIQ2RGBCalculateR.Memoize();
            var    gFunc  = YIQ2RGBCalculateG.Memoize();
            var    bFunc  = YIQ2RGBCalculateB.Memoize();

            byte lum, i, q;

            for (int y = 0; y < rgbImg.Height; y++)
            {
                for (int x = 0; x < rgbImg.Width; x++)
                {
                    int pxIdx = (x + (rgbImg.Width * y));
                    lum = yiqImg.Grid[3 * pxIdx + 2];
                    i   = yiqImg.Grid[3 * pxIdx + 1];
                    q   = yiqImg.Grid[3 * pxIdx + 0];

                    rgbImg.Grid[3 * pxIdx + 0] = bFunc(lum, i, q); // B
                    rgbImg.Grid[3 * pxIdx + 1] = gFunc(lum, i, q); // G
                    rgbImg.Grid[3 * pxIdx + 2] = rFunc(lum, i, q); // R
                }
            }

            return(rgbImg);
        }
        public static CImage ConvertRGBToYIQ(CImage rgbImg)
        {
            CImage yiqImg = new CImage(rgbImg.Width, rgbImg.Height, rgbImg.nBytes);
            var    yFunc  = RGB2YIQCalculateY.Memoize();
            var    iFunc  = RGB2YIQCalculateI.Memoize();
            var    qFunc  = RGB2YIQCalculateQ.Memoize();

            byte r, g, b;

            for (int y = 0; y < rgbImg.Height; y++)
            {
                for (int x = 0; x < rgbImg.Width; x++)
                {
                    int pxIdx = (x + (rgbImg.Width * y));
                    r = rgbImg.Grid[3 * pxIdx + 2];
                    g = rgbImg.Grid[3 * pxIdx + 1];
                    b = rgbImg.Grid[3 * pxIdx + 0];

                    rgbImg.Grid[3 * pxIdx + 0] = qFunc(r, g, b); // Q
                    rgbImg.Grid[3 * pxIdx + 1] = iFunc(r, g, b); // I
                    rgbImg.Grid[3 * pxIdx + 2] = yFunc(r, g, b); // Y
                }
            }

            return(rgbImg);
        }
        public static CImage RotateCCW(CImage original)
        {
            if (original == null)
            {
                throw new ArgumentNullException();
            }

            // Height and width are switched here
            CImage rotatedCCW = new CImage(original.Height, original.Width, original.nBytes);

            int i_orig;
            int i_rotated;
            int maxX = original.Width - 1;

            for (int y = 0; y < original.Height; y++)
            {
                for (int x = maxX; x >= 0; x--)
                {
                    i_orig    = (x + (original.Width * y));
                    i_rotated = y + (rotatedCCW.Width * (maxX - x));

                    for (int i = 0; i < original.nBytes; i++)
                    {
                        rotatedCCW.Grid[i + original.nBytes * i_rotated] = original.Grid[i + original.nBytes * i_orig];
                    }
                }
            }

            return(rotatedCCW);
        }
Example #18
0
        public static int GetThreshold(CImage<double> img)
        {
            int threshold = 0;
              double[] hist = GetHistogram(img);
              double[] D = new double[256];
              for (int t = 0; t < 256; t++)
              {
            double w0 = W(0, t, hist);
            double w1 = W(t + 1, 255, hist);
            double m0 = M(0, t, w0, hist);
            double m1 = M(t + 1, 255, w1, hist);
            D[t] = w0 * w1 * (m0 - m1) * (m0 - m1);
              }

              double DMax = D[0];
              for (int i = 0; i < D.Length; i++)
              {
            if (D[i] > DMax)
            {
              DMax = D[i];
              threshold = i;
            }
              }
              return threshold;
        }
Example #19
0
        public SplashScene(GraphicsDevice graphicsDevice, IContentProvider content, CImage img, CSound snd)
        {
            this.graphicsDevice = graphicsDevice;
            this.content        = content;
            this.img            = img;
            this.snd            = snd;
            this.spriteBatch    = new SpriteBatch(graphicsDevice);

            img.preload(content);

            if (System.Diagnostics.Debugger.IsAttached)
            {
                delay = 500;
            }

            StringBuilder text = new StringBuilder();

            text.AppendLine("Ball: Buster eXtreme");
            text.AppendLine("Copyright 2004-18 Patrick Avella, Erik Ylvisaker");
            text.AppendLine("Game Programming: Patrick Avella (patrickavella.com)");
            text.AppendLine("eXtreme Version Programming: Erik Ylvisaker (vermiliontower.com)");
            text.AppendLine("Game Art: Patrick Avella (patrickavella.com)");
            text.AppendLine("Background Music: Partners in Rhyme (musicloops.com)");
            text.AppendLine("Sound Effects: A1 Free Sound Effects (a1freesoundeffects.com)");

            ContentLayoutEngine layout = new ContentLayoutEngine(img.Fonts);

            textLayout = layout.LayoutContent(text.ToString(), font: new FontStyleProperties {
                Color = Color.Black
            });

            initialDelay = delay;
        }
Example #20
0
        public ActionResult _ImageUploadForm(int imgTyp = -1)
        {
            CImage newImage = new CImage();

            newImage.createdDate = DateTime.Today;
            return(PartialView("_ImageUploadForm", newImage));
        }
        public static CImage FlipVertical(CImage original)
        {
            if (original == null)
            {
                throw new ArgumentNullException();
            }

            CImage verticallyFlipped = new CImage(original.Width, original.Height, original.nBytes);

            int i_orig;
            int i_flipped;
            int maxY = original.Height - 1;

            for (int y = 0; y < original.Height; y++)
            {
                for (int x = 0; x < original.Width; x++)
                {
                    i_orig    = (x + (original.Width * y));
                    i_flipped = (x + (original.Width * (maxY - y)));

                    for (int i = 0; i < original.nBytes; i++)
                    {
                        verticallyFlipped.Grid[i + original.nBytes * i_flipped] = original.Grid[i + original.nBytes * i_orig];
                    }
                }
            }

            return(verticallyFlipped);
        }
Example #22
0
        public static CImage AdjustContrast(CImage image, int contrastFactor)
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }

            if (contrastFactor > 255 || contrastFactor < -255)
            {
                throw new ArgumentException("Value must be between 255 and -255", nameof(contrastFactor));
            }

            if (contrastFactor != 0)
            {
                float contrastModifier = (259 * (255 + contrastFactor)) / (255 * (259 - contrastFactor));

                // We don't vary the calc betwen RGB parts of pixels, so we can just run through the entire array
                var memoizeContrastCalc = calcAdjustedContrastForColor.Memoize();
                for (int i = 0; i < image.Grid.Length; i++)
                {
                    image.Grid[i] = memoizeContrastCalc(image.Grid[i], contrastModifier);
                }
            }

            return(image);
        }
Example #23
0
 static void SubtractNoiseDisp(CImage<double> DImg, double sigma, double X0, CImage<double> img)
 {
     CImage<double> noiseDisp = new CImage<double>(DImg.GetW, DImg.GetH);
     for (int i = 0; i < DImg.GetW; i++)
     {
     for (int j = 0; j < DImg.GetH; j++)
     {
         double buf = DImg[i, j] - GetNoiseDispersion(i, j, img, sigma, X0);
         //if (buf < 0)
         //    DImg[i, j] = 0;
         //else
             DImg[i, j] = buf;
         //img[i, j] = buf < 0 ? 0 : buf;
     }
     }
     double min = DImg.GetMin();
     if (min < 0)
     {
     for (int i = 0; i < DImg.GetH; i++)
     {
         for (int j = 0; j < DImg.GetW; j++)
         {
             DImg[i, j] -= min;
         }
     }
     }
 }
        public static CImage RotateCW(CImage original)
        {
            if (original == null)
            {
                throw new ArgumentNullException();
            }

            // Height and width are switched here
            CImage rotatedCW = new CImage(original.Height, original.Width, original.nBytes);

            // TODO: Review - this seems real wonky
            int i_orig;
            int i_rotated;
            int maxY = original.Height - 1;
            int yIdx = -1;

            for (int y = maxY; y >= 0; y--)
            {
                yIdx += 1;
                for (int x = 0; x < original.Width; x++)
                {
                    i_orig    = (x + (original.Width * y));
                    i_rotated = yIdx + (rotatedCW.Width * x);


                    for (int i = 0; i < original.nBytes; i++)
                    {
                        rotatedCW.Grid[i + original.nBytes * i_rotated] = original.Grid[i + original.nBytes * i_orig];
                    }
                }
            }

            return(rotatedCW);
        }
Example #25
0
        private void ShowImage(CImage image)
        {
            Bitmap cvt_bitmap = new Bitmap(image.nWidth, image.nHeight, image.nChannels * image.nWidth,
                                           System.Drawing.Imaging.PixelFormat.Format24bppRgb, image.pData);

            ShowImage(cvt_bitmap);
        }
Example #26
0
    public static void SaveUGUI(GameObject UI)
    {
        CImage[] sprites = UI.GetComponentsInChildren <CImage>(true);
        for (int j = 0; j < sprites.Length; j++)
        {
            CImage sprite = sprites[j];
            if (!sprite.sprite)
            {
                continue;
            }
            sprite.AtlasName  = sprite.sprite.texture.name.ToLower();;
            sprite.SpriteName = sprite.sprite.name;
        }

        CText[] texts = UI.GetComponentsInChildren <CText>(true);
        for (int j = 0; j < texts.Length; j++)
        {
            CText t = texts[j];
            if (!t.font)
            {
                continue;
            }
            t.FontName = t.font.name;
        }

        AssetDatabase.Refresh();
        AssetDatabase.SaveAssets();
    }
Example #27
0
        public CMessageBox(string message, string caption, CColor.Theme theme, CImage.ImageType image, CMessageBoxButton _buttonType)
        {
            InitializeComponent();
            this.SizeToContent = SizeToContent.Height;
            SystemSounds.Beep.Play();

            //set image
            string imagePath = CImage.GetImagePath(image);

            ImageBrush imgBrush = new ImageBrush
            {
                ImageSource = new BitmapImage(new Uri(imagePath, UriKind.Absolute))
            };

            RCT_image.Fill = imgBrush;

            //set text / caption
            TBL_message.Text          = message;
            windowheader.C_HeaderText = caption;

            //set theme in border and header background
            GRD_border.Background          = CColor.GetColorBrush(theme);
            windowheader.C_BackgroundTheme = theme;

            //enable button by given buttontype
            buttonType = _buttonType;

            switch (buttonType)
            {
            case CMessageBoxButton.OK:
                B_3.Visibility = Visibility.Hidden;
                B_2.Visibility = Visibility.Hidden;
                B_1.Content    = "OK";
                break;

            case CMessageBoxButton.OK_Cancel:
                B_3.Visibility = Visibility.Hidden;
                B_2.Content    = "OK";
                B_1.Content    = "Abbrechen";
                break;

            case CMessageBoxButton.Yes_No:
                B_3.Visibility = Visibility.Hidden;
                B_2.Content    = "Ja";
                B_1.Content    = "Nein";
                break;

            case CMessageBoxButton.Yes_No_Cancel:
                B_3.Content = "Ja";
                B_2.Content = "Nein";
                B_1.Content = "Abbrechen";
                break;

            default:
                break;
            }

            B_1.Focus();
        }
Example #28
0
        }     //****************************** end CheckSmooth **************************************************

        public int SearchPoly(ref CImage Comb, double eps, Form1 fm1)
        {
            int Lab, rv = 0, x, y, y2, CNX = Comb.width, CNY = Comb.height;

            fm1.progressBar1.Value   = 0;
            fm1.progressBar1.Step    = 1;
            fm1.progressBar1.Visible = true;
            int jump, Len = CNY / 2, nStep = 100;

            if (Len > 2 * nStep)
            {
                jump = Len / nStep;
            }
            else
            {
                jump = 2;
            }
            for (y = 0, y2 = 0; y < CNY; y += 2, y2++)
            {
                if ((y2 % jump) == jump - 1)
                {
                    fm1.progressBar1.PerformStep();
                }
                for (x = 0; x < CNX; x += 2)
                {
                    Lab = Comb.Grid[x + CNX * y] & 135;
                    if (Lab == 1 || Lab == 3 || Lab == 4)
                    {
                        rv = ComponPoly(Comb, x, y, eps);
                        if (rv < 0)
                        {
                            MessageBox.Show("SearchPoly, Alarm! ComponPoly returned " + rv);
                            return(-1);
                        }
                    }
                }
            }

            // Starting the search for loops:
            for (y = 0; y < CNY; y += 2)
            {
                for (x = 0; x < CNX; x += 2)
                {
                    Lab = Comb.Grid[x + CNX * y] & 7;
                    if (Lab == 2)
                    {
                        rv = ComponPoly(Comb, x, y, eps);
                        if (rv < 0)
                        {
                            MessageBox.Show("SearchPoly, Alarm! ComponPoly returned " + rv);
                            return(-1);
                        }
                    }
                }
            }
            //fm1.progressBar1.Visible = false;
            return(nVert);
        } //****************************** end SearchPoly ********************************
Example #29
0
        private List <PixelYUV> GenerateYUVCRDataForColorImage(Bitmap bmp)
        {
            List <PixelYUV> imageData = new List <PixelYUV>();
            CImage          colorCImg = new CImage(bmp);

            Bitmap greyBMP = Coloring.ConvertToGrayscale(bmp);
            //greyBMP.Save(@"C:\Temp\SamplesImages\color\v3\ColoredConvertedToGrey.jpg");
            CImage greyCImg = new CImage(greyBMP);

            greyBMP.Dispose();

            // Populate LumGrid
            double[][] lumGrid = new double[greyCImg.Height][];
            for (int y = 0; y < bmp.Height; y++)
            {
                lumGrid[y] = new double[greyCImg.Width];
                for (int x = 0; x < bmp.Width; x++)
                {
                    int i = (x + (bmp.Width * y));
                    lumGrid[y][x] = Utilities.CalcLuminance(
                        greyCImg.Grid[3 * i + 2],   // R
                        greyCImg.Grid[3 * i + 1],   // G
                        greyCImg.Grid[3 * i + 0]    // B
                        );
                }
            }

            // Populate imageData
            for (int y2 = 0; y2 < bmp.Height; y2++)
            {
                for (int x2 = 0; x2 < bmp.Width; x2++)
                {
                    // get neighbours
                    double[] neighbours = Utilities.GetCardinalNeighbours(ref lumGrid, x2, y2);
                    double   mean       = Utilities.GetMeanOfNeighbours(neighbours);
                    int      i2         = (x2 + (bmp.Width * y2));

                    var yuvRow = new PixelYUV()
                    {
                        Y = lumGrid[y2][x2],
                        NeighbourMeanLuminance = mean,
                        NeighbourLuminanceStandardDeviation = Utilities.GetStandardDeviationofNeighbours(neighbours, mean, false),
                    };

                    var tempYUV = new RGB(
                        colorCImg.Grid[3 * i2 + 2],
                        colorCImg.Grid[3 * i2 + 1],
                        colorCImg.Grid[3 * i2 + 0]).ToYUV();

                    yuvRow.U = (float)tempYUV.U;
                    yuvRow.V = (float)tempYUV.V;

                    imageData.Add(yuvRow);
                }
            }

            return(imageData);
        }
Example #30
0
 public void OnClick(int position)
 {
     clickedImage    = items[position];
     ClickedPosition = position;
     if (ItemClick != null)
     {
         ItemClick(this, position);
     }
 }
Example #31
0
        }         //************************************ end BreadthFirst_D ************************************

        public int DarkNoise(ref CImage Image, int minLight, int maxLight, int maxSize, Form1 fm1)
        {
            fm1.progressBar1.Maximum = 100;
            if (maxSize == 0)
            {
                fm1.progressBar1.Step = 100 / 6;
                fm1.progressBar1.PerformStep();
                return(0);
            }
            bool COLOR = (Image.N_Bits == 24);
            int  ind3 = 0, // index multiplied with 3
                 LabelBig2 = 0, Lum = 0, rv = 0;

            fm1.progressBar1.Step    = 1;
            fm1.progressBar1.Visible = true;
            //int jump, Len = maxLight - minLight - 2, nStep = 20;
            int jump, Len = maxLight - minLight - 2, nStep = 30;

            if (Len > 2 * nStep)
            {
                jump = Len / nStep;
            }
            else
            {
                jump = 2;
            }
            for (int light = maxLight - 2; light >= minLight; light--) //===============================
            {
                if (light % jump == jump - 1)
                {
                    fm1.progressBar1.PerformStep();
                }
                for (int i = 0; i < nPixel[light]; i++) //==============================================
                {
                    ind3 = 3 * Index[light][i];
                    if (COLOR)
                    {
                        LabelBig2 = Image.Grid[2 + ind3] & 1;
                        Lum       = MaxC(Image.Grid[2 + ind3], Image.Grid[1 + ind3], Image.Grid[0 + ind3]) & 254;
                    }
                    else
                    {
                        LabelBig2 = Image.Grid[Index[light][i]] & 2;
                        Lum       = Image.Grid[Index[light][i]] & 252;
                    }
                    if (Lum == light && LabelBig2 == 0)
                    {
                        rv = BreadthFirst_D(ref Image, i, light, maxSize, fm1);
                        if (rv < 0)
                        {
                            return(-1);
                        }
                    }
                } //============================= end for (int i.. ===================================
            }     //=============================== end for (int light.. =================================
            return(1);
        }         //********************************* end DarkNoise ******************************************
Example #32
0
        public void ImpulseNoiseReduction_ImageTooSmall()
        {
            Bitmap bmp  = new Bitmap(10, 10);
            CImage cImg = new CImage(bmp);
            Action act  = () => Filters.ImpulseNoiseReduction_Universal(cImg, 20, 20);
            ArgumentOutOfRangeException exc = Assert.Throws <ArgumentOutOfRangeException>(act);

            Assert.Equal("Image needs to be greater than 100 x 100 (Parameter 'original')", exc.Message);
        }
Example #33
0
        /// <summary>
        /// Converts an Image to Sepia
        /// </summary>
        /// <param name="original"></param>
        /// <remarks>Based on explanation here: http://www.aforgenet.com/framework/docs/html/10a0f824-445b-dcae-02ef-349d4057da45.htm</remarks>
        /// <returns></returns>
        public static CImage ConvertToSepia(CImage original)
        {
            if (original == null)
            {
                throw new ArgumentNullException();
            }

            throw new NotImplementedException();
        }
Example #34
0
        private void gridView1_Click(object sender, EventArgs e)
        {
            var sel = gridView1.GetFocusedRow() as tbAlpr;

            if (sel != null)
            {
                pictureBox2.Image = CImage.ByteArrayToImage(sel.PlateImageBg.Data);
            }
        }
Example #35
0
 static void Thresholding(CImage<double> img, double threshold)
 {
     for (int i = 0; i < img.GetH; i++)
       {
     for (int j = 0; j < img.GetW; j++)
     {
       if (img[i, j] > threshold)
     img[i, j] = threshold;
     }
       }
 }
Example #36
0
 static double GetNoiseDispersion(int i, int j, CImage<double> img, double sigma, double X0)
 {
     double D = 0;
     int h = img.GetH;
     int w = img.GetW;
     double M = (img[(i + 1 + w) % w, j]
     + img[(i - 1 + w) % w, j]
     + img[i, (j + 1 + h) % h]
     + img[i, (j - 1 + h) % h]
     + img[i, j]) / 5;
     D = M * sigma * sigma / X0;
     return D;
 }
Example #37
0
 static CImage<double> CImgInv(CImage<double> img)
 {
     CImage<double> OutImg = new CImage<double>(img.GetH, img.GetW);
       double max = img.GetMax();
       for (int i = 0; i < img.GetW; i++)
       {
     for (int j = 0; j < img.GetH; j++)
     {
       OutImg[i, j] = max - img[i, j];
     }
       }
       return OutImg;
 }
Example #38
0
 public static List<Point> GetFoundObj(double threshold, CImage<double> img)
 {
     List<Point> points = new List<Point>();
     for (int i = 0; i < img.GetH; i++)
     {
     for (int j = 0; j < img.GetW; j++)
     {
         if (img[i, j] < threshold)
             points.Add(new Point(i, j));
     }
     }
     return points;
 }
Example #39
0
        public static CImage<double> GetDMatrixImg(double[,] dMatrix, out CImage<double> img, int Size, CImage<double> InImg, double sigma, double X0)
        {
            CImage<double> dImg = new CImage<double>(Size, Size);
              img = CImage<double>.MatrixToCImage(dMatrix, Size);
              SubtractNoiseDisp(img, sigma, X0, InImg);
              double maxValue = img.GetMax();
              dImg = CImage<double>.Norm(img, byte.MaxValue);
              int threshold = OtsuMethod.GetThreshold(dImg);
              double originalThrh = maxValue / byte.MaxValue * threshold;
              Thresholding(img, originalThrh);

              dImg = CImage<double>.Norm(CImgInv(img), byte.MaxValue);
              return dImg;
        }
Example #40
0
        public static CImage<Complex> ToComplex(this CImage<double> img)
        {
            CImage<Complex> cImg = new CImage<Complex>(img.GetH, img.GetW);
              for (int i = 0; i < img.GetH; i++)
              {
            for (int j = 0; j < img.GetW; j++)
            {
              cImg[i, j].Re = img[i, j];
              cImg[i, j].Im = 0;
            }
              }

              return cImg;
        }
Example #41
0
        public static CImage<double> ToDouble(this CImage<Complex> img)
        {
            var cImg = new CImage<double>(img.GetH, img.GetW);
              for (int i = 0; i < img.GetH; i++)
              {
            for (int j = 0; j < img.GetW; j++)
            {
              //cImg[i, j] = img[i, j].Abs;
              cImg[i, j] = img[i, j].Re;
            }
              }

              return cImg;
        }
Example #42
0
 public static CImage<double> GenareteACF(int height, int width, double alfa, double Df)
 {
     CImage<double> ACFimg = new CImage<double>(height, width);
       for (int i = 0; i < height; i++)
       {
     int ii = i - height / 2;
     for (int j = 0; j < width; j++)
     {
       int jj = j - width / 2;
       ACFimg[(i + height / 2) % height, (j + width / 2) % width] = Df * Math.Exp(-alfa * Math.Sqrt(ii * ii + jj * jj));
     }
       }
       return ACFimg;
 }
Example #43
0
        public static CImage<double> GenarateNoise(int height, int width, int seed)
        {
            Random rnd = new Random(seed);

              CImage<double> nImg = new CImage<double>(height, width);
              for (int i = 0; i < height; i++)
              {
            for (int j = 0; j < width; j++)
            {
              nImg[i, j] = (rnd.NextDouble() - 0.5) / Math.Sqrt(1.0 / 12.0);
            }
              }
              return nImg;
        }
Example #44
0
        public static CImage<Complex> BackwardFFT2D(CImage<Complex> img)
        {
            IntPtr pin, pout;
              IntPtr fplan1; //fplan2, fplan3;
              int h = img.GetH;
              int w = img.GetW;

              pin = fftw.malloc(h * w * 16);
              pout = fftw.malloc(h * w * 16);

              unsafe
              {
            double* pfin = (double*)pin;
            double* pfout = (double*)pout;

            for (int i = 0; i < h; i++)
            {
              for (int j = 0; j < w; j++)
              {
            pfin[(i * h + j) * 2] = img[i, j].Re;
            pfin[(i * h + j) * 2 + 1] = img[i, j].Im;
              }

            }

              }
              fplan1 = fftw.dft_2d(h, w, pin, pout, fftw_direction.Backward, fftw_flags.Estimate);
              fftw.execute(fplan1);

              double normalize = h * w;

              CImage<Complex> cImg = new CImage<Complex>(h, w);
              unsafe
              {
            double* buf = (double*)pout;
            for (int i = 0; i < h; i++)
            {
              for (int j = 0; j < w; j++)
              {
            cImg[i, j].Re = buf[(i * h + j) * 2] / normalize;
            cImg[i, j].Im = buf[(i * h + j) * 2 + 1] / normalize;
              }
            }
              }

              fftw.free(pin);
              fftw.free(pout);
              fftw.destroy_plan(fplan1);
              return cImg;
        }
Example #45
0
 public static double[] GetHistogram(CImage<double> img)
 {
     double[] hist = new double[256];
       for (int i = 0; i < img.GetH; i++)
       {
     for (int j = 0; j < img.GetW; j++)
     {
       hist[(int)img[i, j]]++;
     }
       }
       for (int i = 0; i < 256; i++)
     {
          hist[i]/=(img.GetW*img.GetH);
     }
       return hist;
 }
Example #46
0
 public static void GetDispMatrix(CImage<double> img, int r, out double[,] dispersion)
 {
     int heigth = img.GetH;
      int width = img.GetW;
      dispersion = new double[width, heigth];
      List<Point> circle = Bresenham.GetFullCircle(Bresenham.GetCircle(0, 0, r), new Point(0, 0));
      for (int i = 0; i < heigth; i++)
      {
      for (int j = 0; j < width; j++)
      {
          List<Point> c = new List<Point>();
          foreach (Point p in circle)
          {
              c.Add(new Point((j + p.x + width) % width, (i + p.y + heigth) % heigth));
          }
          double mean = GetMean(img, c);
          double d = GetDispersion(img, c, mean);
          dispersion[j, i] = d;
      }
      }
 }
Example #47
0
        public static List<Point> GetObjects(CImage<double> background, out CImage<double> img, int r, double Q, int Xmin, int Xmax, bool crossing)
        {
            List<Point> obj = new List<Point>();
              int height = background.GetH;
              int width = background.GetW;
              img = background.Copy();
              int ObjNumber = GetNumber(height, width, Q, r);
              Random rndX = new Random(1);
              Random rndY = new Random(9);
              Random rndL = new Random(5);
              for (int i = 0; i < ObjNumber; i++)
              {
            int X, Y;
            int L = rndL.Next(Xmin, Xmax + 1);
            if (!crossing)
            {
              Point point = GetNewPoint(obj, rndX, rndY, height, width, r);
              obj.Add(point);
              X = point.x;
              Y = point.y;
            }
            else
            {
              X = rndX.Next(0, width + 1);
              Y = rndY.Next(0, height + 1);
              obj.Add(new Point(X, Y));
            }
              List<Point> points = new List<Point>();
              points = Bresenham.GetCircle(X,Y,r);
              points = Bresenham.GetFullCircle(points, new Point(X, Y));
              foreach (Point p in points)
              {
            int x = (p.x + width) % width;
            int y = (p.y + height) % height;
            img[x, y] = L;
              }

              }
              return obj;
        }
Example #48
0
 private void VITBtn_Click(object sender, EventArgs e)
 {
     VITModel model = new VITModel(param.R, param.L1, param.L2, param.S1, param.S2, param.K, 0,0,0, param.Size, bgAndObj.GetH);
       vitImg = model.AppVIT(bgAndObj, OptSysCheckBox.Checked, H0CheckBox.Checked, HkCheckBox.Checked, NoiseCheckBox.Checked, param.Sigma, param.X0);
       pictureBox2.Image = vitImg.CImageToBitmap();
       vitImg.CImageToBitmap().Save("vit.bmp");
 }
Example #49
0
        private void VITAnalyssBTN_Click(object sender, EventArgs e)
        {
            CImage<double> background4N = Background.GetBackground(1024, 1024, param.Alfa, param.Df, param.Mf);
            CImage<double> bgAndObj4N = new CImage<double>(1024, 1024);
            Objects.GetObjects(background4N, out bgAndObj4N, 1024 / 256 * param.Radius, param.Q, param.Xmin, param.Xmax, !checkBox1.Checked);
            CImage<double> bgAndObj2N = new CImage<double>(512, 512);
            for (int i = 0; i < 512; i++)
            {
            for (int j = 0; j < 512; j++)
            {
                bgAndObj2N[i, j] = bgAndObj4N[i * 2, j * 2];
            }
            }

            CImage<double> bgAndObjN = new CImage<double>(256, 256);
            for (int i = 0; i < 256; i++)
            {
            for (int j = 0; j < 256; j++)
            {
                bgAndObjN[i, j] = bgAndObj4N[i * 4, j * 4];
            }
            }

            VITModel modelN = new VITModel(param.R, param.L1, param.L2, param.S1, param.S2, param.K, 0, 0, 0, 256, 256);
            CImage<double> vitImgN = modelN.AppVIT(bgAndObjN, OptSysCheckBox.Checked, H0CheckBox.Checked, HkCheckBox.Checked, NoiseCheckBox.Checked, param.Sigma, param.X0);

            VITModel model2N = new VITModel(param.R, param.L1, param.L2, param.S1, param.S2, param.K, 0, 0, 0, 256, 512);
            CImage<double> vitImg2N = model2N.AppVIT(bgAndObj2N, OptSysCheckBox.Checked, H0CheckBox.Checked, HkCheckBox.Checked, NoiseCheckBox.Checked, param.Sigma, param.X0);

            VITModel model4N = new VITModel(param.R, param.L1, param.L2, param.S1, param.S2, param.K, 0, 0, 0, 256, 1024);
            CImage<double> vitImg4N = model4N.AppVIT(bgAndObj4N, OptSysCheckBox.Checked, H0CheckBox.Checked, HkCheckBox.Checked, NoiseCheckBox.Checked, param.Sigma, param.X0);

            pictureBox1.Image = vitImgN.CImageToBitmap();
            pictureBox2.Image = vitImg2N.CImageToBitmap();
            pictureBox3.Image = vitImg4N.CImageToBitmap();

            double SKO = 0;
            for (int i = 0; i < 256; i++)
            {
            for (int j = 0; j < 256; j++)
            {
                SKO += ((vitImgN[i, j] - vitImg2N[i, j]) * (vitImgN[i, j] - vitImg2N[i, j]));
            }
            }
            SKO /= (256 * 256);
            SKOTB12.Text = SKO.ToString();
            SKO = 0;
            for (int i = 0; i < 256; i++)
            {
            for (int j = 0; j < 256; j++)
            {
                SKO += ((vitImg2N[i, j] - vitImg4N[i, j]) * (vitImg2N[i, j] - vitImg4N[i, j]));
            }
            }
            SKO /= (256 * 256);
            SKOTB24.Text = SKO.ToString();
        }
Example #50
0
        private void ObjBtn_Click(object sender, EventArgs e)
        {
            ObjList.Items.Clear();
            List<ImageProcessing.Point> obj_big = (Objects.GetObjects(background, out bgAndObj_big, param.IMGSize/256* param.Radius, param.Q, param.Xmin, param.Xmax, !checkBox1.Checked)).OrderBy(x=>x.x).ThenBy(y=>y.y).ToList();
            bgAndObj_big.CImageToBitmap().Save("img.bmp");

            bgAndObj = new CImage<double>(256, 256);
            int k = param.IMGSize/256;
            for (int i = 0; i < 256; i++)
            {
            for (int j = 0; j < 256; j++)
            {
            bgAndObj[i, j] = bgAndObj_big[i * k, j * k];
            }
            }
            //pictureBox2.Image = bgAndObj.CImageToBitmap();
               obj = new List<ImageProcessing.Point>();
            foreach (ImageProcessing.Point p in obj_big)
             {
            obj.Add(new ImageProcessing.Point(p.x/k, p.y/k));
             }
            foreach (ImageProcessing.Point p in obj)
            {
            ObjList.Items.Add(p);
            }
            pictureBox1.Image = bgAndObj.CImageToBitmap();
        }
Example #51
0
 public void GenerateHopt(bool added)
 {
     _Hopt = new CImage<double>(Size, Size);
       for (int i = 0; i < Size; i++)
       {
     int ii = i - Size / 2;
     for (int j = 0; j < Size; j++)
     {
       int jj = j - Size / 2;
       if (added)
     _Hopt[(i + Size / 2) % Size, (j + Size / 2) % Size] = Hopt(ii, jj);
       else
     _Hopt[(i + Size / 2) % Size, (j + Size / 2) % Size] = 1.0;
     }
       }
 }
Example #52
0
		private unsafe void copy24(Bitmap b,CImage img,int x,int y)
		{
			for(int row=0;row<b.Height;row++)
				for(int col=0;col<b.Width;col++)
				{
					Color c = b.GetPixel(col,row);
					*(img.m_pBitmap+((y+row)*img.m_Xres*3)+((x+col)*3))=c.B;
					*(img.m_pBitmap+((y+row)*img.m_Xres*3)+((x+col)*3+1))=c.G;
					*(img.m_pBitmap+((y+row)*img.m_Xres*3)+((x+col)*3+2))=c.R;
				}
		}
Example #53
0
		public static unsafe void writeCImage(CImage img, string outFile)
		{
			BinaryWriter bw = new BinaryWriter(File.OpenWrite(outFile));

			int more = 0;
			while((img.m_Xres*3+more)%4!=0)
				more++;

			int len = (img.m_Xres*3+more)*img.m_Yres;
			bw.Write('B');//must always be set to 'BM' to declare that this is a .bmp-file.
			bw.Write('M');
			bw.Write(14+40+len);//specifies the size of the file in bytes.
			bw.Write((int)0); //zero
			bw.Write((int)14+40); //specifies the offset from the beginning of the file to the bitmap data.

			bw.Write((int)40);//specifies the size of the BITMAPINFOHEADER structure, in bytes
			bw.Write((int)img.m_Xres);
			bw.Write((int)img.m_Yres);
			bw.Write((short)1);//specifies the number of planes of the target device
			bw.Write((short)24);//specifies the number of bits per pixel
			bw.Write((int)0);
			bw.Write((int)0);
			bw.Write((int)0);
			bw.Write((int)0);
			bw.Write((int)0);
			bw.Write((int)0);

			byte* pix=img.m_pBitmap;
			pix+=img.m_NumPixel*3;
	
			for (int i=0; i<img.m_Yres; i++)
			{
				pix-=img.m_Xres*3;

				for(int j=0;j<img.m_Xres*3;j++)
					bw.Write((byte)*(pix+j));

				for(int j=0;j<more;j++)
					bw.Write((byte)0x00);
			}

			bw.Flush();
			bw.Close();	
		}
Example #54
0
 public void GenerateVIT()
 {
     VIT = new CImage<double>(Size, Size);
       for (int i = 0; i < Size; i++)
       {
     for (int j = 0; j < Size; j++)
     {
       VIT[i, j] = _Hopt[i, j] * _H0[i, j] *_Hk[i, j];
     }
       }
 }
Example #55
0
        public CImage<double> AppVIT(CImage<double> img, bool addHopt, bool addH0, bool addHk, bool addNoise, double sigma, double X0)
        {
            int height = img.GetH;
              int width = img.GetW;
              //CImage<double> imgOut = new CImage<double>(height, width);
              CImage<double> imgOut = new CImage<double>(oSize, oSize);

            GenerateH0(addH0);
            GenerateHk(addHk);
            GenerateHopt(addHopt);
            GenerateVIT();

            CImage<Complex> fImg = FourierTransform.ForwardFFT2D(img.ToComplex());
            CImage<Complex> fVIT = VIT.ToComplex();
            for (int i = 0; i < Size; i++)
            {
              for (int j = 0; j < Size; j++)
              {
            fImg[i, j] = fImg[i, j] * fVIT[i, j];
              }
            }
            img = FourierTransform.BackwardFFT2D(fImg).ToDouble();

            int k = Size / oSize;
            for (int i = 0; i < oSize; i++)
            {
            for (int j = 0; j < oSize; j++)
            {
                imgOut[i, j] = img[i * k, j * k];
            }
            }

            if (addNoise)
            {
              Random rnd = new Random(7);
              for (int i = 0; i < oSize; i++)
              {
              for (int j = 0; j < oSize; j++)
            {
                double buf = imgOut[i, j] + GenerateNormNoise(rnd, sigma, X0) * Math.Sqrt(imgOut[i, j]);
                if (buf > 255)
                    imgOut[i, j] = 255;
                else
                    if (buf < 0)
                        imgOut[i, j] = 0;
                    else imgOut[i, j] = buf;

                //imgOut[i, j] = buf < 255 ? buf : 255;
                //imgOut[i, j] = buf > 0 ? buf : 0;
            }
              }
            }
            //for (int i = 0; i < Size; i++)
            //{
            //  for (int j = 0; j < Size; j++)
            //  {
            //    imgOut[i, j] = imgOut[i, j] + 128;
            //  }
            //}

              return imgOut;
        }
Example #56
0
 static double GetDispersion(CImage<double> img, List<Point> points, double mean)
 {
     double d = 0;
      foreach (var p in points)
      {
      double X = img[p.x, p.y];
      d += ((img[p.x, p.y] - mean) * (img[p.x, p.y] - mean));
      }
      d /= points.Count();
      return d;
 }
Example #57
0
 private void BackgroundBtn_Click(object sender, EventArgs e)
 {
     background = Background.GetBackground(param.IMGSize, param.IMGSize, param.Alfa, param.Df, param.Mf);
       pictureBox1.Image = background.CImageToBitmap();
       background.CImageToBitmap().Save("bg.bmp");
 }
Example #58
0
		public static unsafe Bitmap Hq2x(Bitmap image)
		{
#if hq2xWorks
			CImage in24 = new CImage();
			in24.Init(image.Width,image.Height,24);

			for(int row=0;row<image.Height;row++)
				for(int col=0;col<image.Width;col++)
				{
					Color c = image.GetPixel(col,row);
					*(in24.m_pBitmap+((row)*in24.m_Xres*3)+((col)*3))=c.B;
					*(in24.m_pBitmap+((row)*in24.m_Xres*3)+((col)*3+1))=c.G;
					*(in24.m_pBitmap+((row)*in24.m_Xres*3)+((col)*3+2))=c.R;
				}					

			in24.ConvertTo16();
			
			CImage out32 = new CImage();
			out32.Init(in24.m_Xres*2,in24.m_Yres*2,32);

			CImage.InitLUTs();
			CImage.hq2x_32(in24.m_pBitmap,out32.m_pBitmap,in24.m_Xres,in24.m_Yres,out32.m_Xres*4);

			out32.ConvertTo24();

			Bitmap b = new Bitmap(out32.m_Xres,out32.m_Yres,PixelFormat.Format24bppRgb);
			//Rectangle   rect = new Rectangle(0, 0, b.Width,b.Height);
			BitmapData bitmapData = b.LockBits(new Rectangle(0, 0, b.Width,b.Height),ImageLockMode.WriteOnly,b.PixelFormat);

			IntPtr pixels = bitmapData.Scan0;

			byte *  pBits;
			if (bitmapData.Stride > 0)
				pBits = (byte *)pixels.ToPointer();
			else
				pBits = (byte *)pixels.ToPointer() + bitmapData.Stride*(b.Height-1);

			byte* srcBits = out32.m_pBitmap;
			for (int i=0;i<b.Width*b.Height;i++)
			{
				*(pBits++)=*(srcBits++);
				*(pBits++)=*(srcBits++);
				*(pBits++)=*(srcBits++);
			}
			
			b.UnlockBits(bitmapData);
			
			image.Dispose();
			in24.__dtor();
			out32.__dtor();

			return b;
#else
			return null;
#endif
		}
Example #59
0
 static double GetMean(CImage<double> img, List<Point> points)
 {
     double mean = 0;
      foreach (var p in points)
      {
      double buf = img[p.x, p.y];
      mean += img[p.x, p.y];
      }
      mean /= points.Count();
      return mean;
 }
Example #60
0
 public static void MarkPoint(List<Point> points, CImage<double> img)
 {
     foreach (var p in points)
     {
     img[p.x, p.y] = 255;
     }
 }