Ejemplo n.º 1
0
        public override QBitmap processImage(QBitmap sourceImage, BackgroundWorker worker)
        {
            QBitmap resultImage = new QBitmap(sourceImage, false);
            int     ImgsW       = sourceImage.Width;
            int     ImgsH       = sourceImage.Height;

            int MaskW = Mask.SizeX;
            int MaskH = Mask.SizeY;

            for (int y = MaskH / 2; y < ImgsH - MaskH / 2; y++)
            {
                worker.ReportProgress(progressOffs + (int)(((float)y * progressPerc) / (ImgsH - MaskH)));
                if (worker.CancellationPending)
                {
                    return(null);
                }

                for (int x = MaskW / 2; x < ImgsW - MaskW / 2; x++)
                {
                    resultImage.SetPixel(x, y, calculateNewPixelColor(sourceImage, x, y));
                }
            }

            return(resultImage);
        }
Ejemplo n.º 2
0
        public override QBitmap processImage(QBitmap sourceImage, BackgroundWorker worker)
        {
            AvgColors(sourceImage, worker);

            for (int i = 0; i < sourceImage.Width; i++)
            {
                worker.ReportProgress(50 + (int)((float)i / sourceImage.Width * progress));
                if (worker.CancellationPending)
                {
                    return(null);
                }

                for (int j = 0; j < sourceImage.Height; j++)
                {
                    sourceImage.SetPixel(i, j, calculateNewPixelColor(sourceImage, i, j));
                }
            }

            return(sourceImage);
        }
Ejemplo n.º 3
0
        //общая для всех фильтров часть
        public virtual QBitmap processImage(QBitmap sourceImage, BackgroundWorker worker)
        {
            QBitmap resultImage = new QBitmap(sourceImage, false);

            for (int i = 0; i < sourceImage.Width; i++)
            {
                worker.ReportProgress(progressOffs + (int)((float)i / resultImage.Width * progressPerc));
                if (worker.CancellationPending)
                {
                    return(null);
                }

                for (int j = 0; j < sourceImage.Height; j++)
                {
                    resultImage.SetPixel(i, j, calculateNewPixelColor(sourceImage, i, j));
                }
            }

            return(resultImage);
        }
Ejemplo n.º 4
0
        public override QBitmap processImage(QBitmap sourceImage, BackgroundWorker worker)
        {
            int ImgsW = sourceImage.Width;
            int ImgsH = sourceImage.Height;

            for (int x = 0; x < ImgsW; x++)
            {
                worker.ReportProgress((int)((float)x / (ImgsW) * progressPerc));
                if (worker.CancellationPending)
                {
                    return(null);
                }

                for (int y = 0; y < ImgsH; y++)
                {
                    sourceImage.SetPixel(x, y, calculateNewPixelColor(sourceImage, x, y));
                }
            }

            return(sourceImage);
        }
Ejemplo n.º 5
0
        public override QBitmap processImage(QBitmap sourceImage, BackgroundWorker worker)
        {
            int percentage = 33 * progressPerc / 100;

            QBitmap SobelXImage = (new SobelXFilter(percentage, 0)).processImage(sourceImage, worker);
            QBitmap SobelYImage = (new SobelYFilter(percentage, percentage)).processImage(sourceImage, worker);

            QBitmap resultImage = new QBitmap(sourceImage, false);

            for (int i = 0; i < sourceImage.Width; i++)
            {
                worker.ReportProgress(2 * percentage + (int)((float)i / resultImage.Width * percentage));//сигнализирует элементу BackgroundWorker о текущем процессе
                if (worker.CancellationPending)
                {
                    return(null);
                }

                for (int j = 0; j < sourceImage.Height; j++)
                {
                    (byte xR, byte xG, byte xB) = SobelXImage.GetPixel(i, j);
                    (byte yR, byte yG, byte yB) = SobelYImage.GetPixel(i, j);

                    double dch = 0;

                    dch += xR * xR;
                    dch += xG * xG;
                    dch += xB * xB;

                    dch += yR * yR;
                    dch += yG * yG;
                    dch += yB * yB;

                    resultImage.SetPixel(i, j, Math.Sqrt(dch));
                }
            }

            return(resultImage);
        }