コード例 #1
0
ファイル: Filtering.cs プロジェクト: HungryBear/rayden
        public FilterLUT(Filter filter, float offsetX, float offsetY)
        {
            int x0 = MathLab.Ceil2UInt(offsetX - filter.xWidth);
            int x1 = MathLab.Floor2UInt(offsetX + filter.xWidth);
            int y0 = MathLab.Ceil2UInt(offsetY - filter.yWidth);
            int y1 = MathLab.Floor2UInt(offsetY + filter.yWidth);
            lutWidth = x1 - x0 + 1;
            lutHeight = y1 - y0 + 1;
            lut = new float[lutWidth * lutHeight];

            float filterNorm = 0f;
            int index = 0;
            for (int iy = y0; iy <= y1; ++iy)
            {
                for (int ix = x0; ix <= x1; ++ix)
                {
                    float filterVal = filter.Evaluate(Math.Abs(ix - offsetX), Math.Abs(iy - offsetY));
                    filterNorm += filterVal;
                    lut[index++] = filterVal;
                }
            }

            // Normalize LUT
            filterNorm = 1f / filterNorm;
            index = 0;
            for (int iy = y0; iy <= y1; ++iy)
            {
                for (int ix = x0; ix <= x1; ++ix)
                    lut[index++] *= filterNorm;
            }
        }
コード例 #2
0
ファイル: Filtering.cs プロジェクト: HungryBear/rayden
        public FilterLUTs(Filter filter, int size)
        {
            lutsSize = size + 1;
            step = 1f / (float)(size);

            luts = new FilterLUT[lutsSize * lutsSize];

            for (var iy = 0; iy < lutsSize; ++iy)
            {
                for (var ix = 0; ix < lutsSize; ++ix)
                {
                    float x = ix * step - 0.5f + step / 2f;
                    float y = iy * step - 0.5f + step / 2f;

                    luts[ix + iy * lutsSize] = new FilterLUT(filter, x, y);
                    /*std::cout << "===============================================\n";
                    std::cout << ix << "," << iy << "\n";
                    std::cout << x << "," << y << "\n";
                    std::cout << *luts[ix + iy * lutsSize] << "\n";
                    std::cout << "===============================================\n";*/
                }
            }
        }
コード例 #3
0
ファイル: ImageFilmBase.cs プロジェクト: HungryBear/rayden
        public ImageFilmBase(int width, int height)
        {
            this.Width = width;
            this.Height = height;
            this.Samples = new SampleBuffer((SampleBufferSize));
            this.frameBuffer = new FrameBuffer(width, height);
            this.InitGammaTable();
            this.pixelData = new SamplePixel[width * height];
            this.statsImage = new SamplePixel[width * height];
            //RgbSpectrum.Gamma = true;
            if (this.ToneMap)
            {
                switch (GlobalConfiguration.Instance.ToneMapType)
                {
                    case 1:
                        float scale = float.Parse(GlobalConfiguration.Instance.ToneMapParams);
                        ToneMapping = new LinearToneMap(this, scale);
                        break;
                    case 2:
                        ToneMapping = new ReinhardToneMap(this);
                        break;
                    case 3:
                        ToneMapping = new QuadricToneMap(this);
                        break;
                }

                this.toneMap = new Reinhard02ToneMapParams();
                //new LinearToneMapParams(linearToneMapValue);
            }

            if (this.Filter)
            {
                switch (FilterType)
                {
                    case 0:
                        filter = new BoxFilter(1.2f, 1.2f);
                        break;
                    case 1:
                        this.filter = new GaussianFilter(filterSize, filterSize);
                        break;
                    case 2:
                        this.filter = new MitchelFilter(filterSize, filterSize);
                        break;
                    default:
                        filter = new BoxFilter(1.2f, 1.2f);
                        break;
                }
                Tracer.TraceLine("Image filter used : {0}", filter.GetType().Name);
                if (filter == null)
                {
                    this.filter =
                        //new BoxFilter(1.2f, 1.2f);
                        new GaussianFilter(filterSize, filterSize);
                }
                this.filterLUTs = new FilterLUTs(this.filter, filterTableSize);
            }

            this.sampleBuffers = new List<SampleBuffer>();
            this.freeSampleBuffers = new ConcurrentQueue<SampleBuffer>();
        }