Exemple #1
0
 private void button1_Click(object sender, System.EventArgs e)
 {
     if (!StartingTextureMapValid)
     {
         MessageBox.Show("Please load a valid source texture map first."); return;
     }
     QuiltedTextureMap = ImageQuilter.QuiltTextureMap(
         this.StartingTextureMap,
         (int)this.numericUpDownQuiltingWidth.Value,
         (int)this.numericUpDownQuiltingHeight.Value,
         (int)this.numericUpDownQuiltingBlockSize.Value,
         (int)this.numericUpDownQuiltingBlockOverlap.Value,
         (int)this.numericUpDownNumCandidateQuiltBlocks.Value,
         (int)this.numericUpDownSelectFromNBestCandidateQuiltErrorTolerance.Value
         );
     UpdateDisplay();
 }
Exemple #2
0
        void DoTextureTransfer()
        {
            int   numIterations           = (int)this.numericUpDownNumIterations.Value;
            int   blockSize               = (int)this.numericUpDownLargestQuiltingBlockSize.Value;
            float blocksizeOverlapPercent = (float)this.numericUpDownQuiltingBlockOverlap.Value;
            int   numCandidateQuiltBlocks = (int)this.numericUpDownNumCandidateQuiltBlocks.Value;
            float errorTolerance          = (float)numericUpDownSelectFromNBestCandidateQuiltErrorTolerance.Value;


            float blocksizeReductionPerIter = (float)this.numericUpDownBlockReductionPer.Value;

            for (int iteration = 0; iteration < numIterations; iteration++)
            {
                int blockOverlap = (int)((float)blockSize * blocksizeOverlapPercent);
                if (blockOverlap < 3)
                {
                    blockOverlap = 3;
                }
                float alpha = 0.8f * ((float)(iteration + 1 - 1)) / ((float)(numIterations - 1)) + 0.1f;
                Util.Spew("Iteration " + (iteration + 1) + ": alpha " + alpha + ", blockSize " + blockSize + " overlap " + blockOverlap);

                // do it
                this.PreviousIterationQuiltedTexture = ImageQuilter.TextureTransfer(
                    this.SourceTexture, this.SourceTextureCMap,
                    this.TargetTexture, this.TargetTextureCMap,
                    this.PreviousIterationQuiltedTexture,
                    blockSize, blockOverlap,
                    numCandidateQuiltBlocks, errorTolerance,
                    alpha
                    );

                this.UpdateDisplay();

                blockSize = (int)((float)blockSize * (1f - blocksizeReductionPerIter));
                if (blockSize < 4)
                {
                    blockSize = 4;
                }
            }
            this.CurrentQuiltedTexture = PreviousIterationQuiltedTexture;
            UpdateDisplay();
        }