コード例 #1
0
        /// <summary>
        /// Directly creates a blured image out of the greyscale input texture using the quantum blur algorithm.
        /// The blur is done via rotating qubits (in radian). Supports logarithmic encoding.
        /// </summary>
        /// <param name="inputTexture">The image on which the blur should be applied.</param>
        /// <param name="rotation">The rotation which should be applied in radian.</param>
        /// <param name="useLog">If logarithmic encoding (and decoding) should be used</param>
        /// <param name="useDifferentDecoding">If the decoding used should be not the same as the encoding (for example if you only want to sue logarithmic decoding)</param>
        /// <param name="doFast">If the (most of the time) faster creation of color image should be used.</param>
        /// <returns></returns>
        public Texture2D CreateBlurTextureColor(Texture2D inputTexture, float rotation, bool useLog = false, bool useDifferentDecoding = false, bool doFast = false)
        {
            Texture2D OutputTexture;

            double[,] imageData = QuantumImageHelper.GetRedHeightArray(inputTexture);
            QuantumCircuit redCircuit = getBlurCircuitFromData(imageData, rotation, useLog);

            QuantumImageHelper.FillGreenHeighArray(inputTexture, imageData);
            QuantumCircuit greenCircuit = getBlurCircuitFromData(imageData, rotation, useLog);

            QuantumImageHelper.FillBlueHeighArray(inputTexture, imageData);
            QuantumCircuit blueCircuit = getBlurCircuitFromData(imageData, rotation, useLog);

            if (useDifferentDecoding)
            {
                useLog = !useLog;
            }

            if (doFast)
            {
                OutputTexture = GetColoreTextureFast(redCircuit, greenCircuit, blueCircuit, useLog);
            }
            else
            {
                OutputTexture = GetColoreTexture(redCircuit, greenCircuit, blueCircuit, useLog);
            }

            return(OutputTexture);
        }