All pastes #2052166 Raw Edit

Stuff

public text v1 · immutable
#2052166 ·published 2011-04-30 09:14 UTC
rendered paste body
public double Moment(char obraz, int p, int q, Point minX, Point maxX, Point minY, Point maxY)
        { // vstupni parametry jsou 
obraz (na jakém obrazu A nebo B bude vypočítán),
            double moment = 0;
            for (int x = minX.X; x <= maxX.X; x++)
            {
                for (int y = minY.Y; y <= maxY.Y; y++)
                {
                    Color barva;
                    double stupenSedi = 0;
                    
                    if (obraz == 'A')
                    {
                        
                        barva = pictureFiltrA.GetPixel(x, y);
                        if (barva.A < 100)
                        {
                            stupenSedi = 0;
                        }
                        else
                        {
                            stupenSedi = barva.R * 0.299 + barva.G * 0.587 + barva.B * 0.114;
                        }
                    }
                    if (obraz == 'B')
                    {
                        barva = pictureFiltrB.GetPixel(x, y);
                        if (barva.A < 100)
                        {
                            stupenSedi = 0;
                        }
                        else
                        {
                            stupenSedi = barva.R * 0.299 + barva.G * 0.587 + barva.B * 0.114;
                        }
                    }
                    
                    moment += (x ^ p) * (y ^ q) * (stupenSedi / 255);   // stupenSedi je ve formatu 0-255
                }
            }
            return moment/((maxX.X-minX.X)*(maxY.Y-minY.Y));
        }