コード例 #1
0
        IronPython.Runtime.PythonDictionary getTeleportDictionaryFromData(out string heightDimensions, double[,] imageData, double[,] imageData2, double mixture, double normalization = 0, bool useLog = false)
        {
            dynamic teleportationHelper = pythonFile.TeleportationHelper("TeleportationHelper");

            bool normalizeManually = normalization > 0;

            teleportationHelper.SetHeights(imageData, imageData2, imageData.GetLength(0), imageData.GetLength(1));
            teleportationHelper.ApplySwap(mixture, useLog, normalizeManually);
            dynamic circuit = teleportationHelper.GetCircuit();


            int numberofQubits = circuit.num_qubits;

            heightDimensions = circuit.name;

            QuantumCircuit       quantumCircuit = QuantumImageHelper.ParseCircuit(circuit.data, numberofQubits);
            MicroQiskitSimulator simulator      = new MicroQiskitSimulator();

            quantumCircuit.Normalize();

            double[] doubleArray = new double[0];
            string[] stringArray = new string[0];

            double[] probs = simulator.GetProbabilities(quantumCircuit);


            QuantumImageHelper.GetProbabilityArrays(probs, numberofQubits, ref doubleArray, ref stringArray);

            IronPython.Runtime.PythonDictionary dictionary = pythonFile.CombinedHeightFromProbabilities(stringArray, doubleArray, doubleArray.Length, numberofQubits, heightDimensions, useLog, normalization);
            return(dictionary);
        }
コード例 #2
0
        /// <summary>
        /// Constructing a greyscale image from a single quantumCircuit (which should represent a greyscale image).
        /// Used after image effect are applied to the image (the circuit) to get the modified picture.
        /// </summary>
        /// <param name="quantumCircuit">The circuit representing the (modified) image.</param>
        /// <param name="useLog">If logarithmic decoding should be used to decode the image.</param>
        /// <returns></returns>
        public Texture2D GetGreyTexture(QuantumCircuit quantumCircuit, bool useLog = false)
        {
            MicroQiskitSimulator simulator = new MicroQiskitSimulator();

            double[] doubleArray = new double[0];
            string[] stringArray = new string[0];

            QuantumImageHelper.GetProbabilityArrays(simulator.GetProbabilities(quantumCircuit), quantumCircuit.NumberOfQubits, ref doubleArray, ref stringArray);
            IronPython.Runtime.PythonDictionary dictionary = pythonFile.HeightFromProbabilities(stringArray, doubleArray, doubleArray.Length, quantumCircuit.DimensionString, useLog);

            return(QuantumImageHelper.CalculateGreyTexture(dictionary, quantumCircuit.DimensionString));
        }
コード例 #3
0
        /// <summary>
        /// Constructing a colored image from 3 quantumCircuits, 1 per channel, (which should represent a colored image).
        /// Used after image effect are applied to the image (the circuit) to get the modified picture
        /// </summary>
        /// <param name="redCircuit">The circuit representing the red color channel of the (modified) image.</param>
        /// <param name="greenCircuit">The circuit representing the green color channel of the (modified) image</param>
        /// <param name="blueCircuit">The circuit representing the blue color channel of the (modified) image</param>
        /// <param name="useLog">If logarithmic decoding should be used to decode the image.</param>
        /// <returns></returns>
        public Texture2D GetColoreTexture(QuantumCircuit redCircuit, QuantumCircuit greenCircuit, QuantumCircuit blueCircuit, bool useLog = false)
        {
            MicroQiskitSimulator simulator = new MicroQiskitSimulator();

            //TODO OPTIMIZATIOn initialize arrays only once
            double[] doubleArray = new double[0];
            string[] stringArray = new string[0];

            QuantumImageHelper.GetProbabilityArrays(simulator.GetProbabilities(redCircuit), redCircuit.NumberOfQubits, ref doubleArray, ref stringArray);
            IronPython.Runtime.PythonDictionary redDictionary = pythonFile.HeightFromProbabilities(stringArray, doubleArray, doubleArray.Length, redCircuit.DimensionString, useLog);

            QuantumImageHelper.GetProbabilityArrays(simulator.GetProbabilities(greenCircuit), greenCircuit.NumberOfQubits, ref doubleArray, ref stringArray);
            IronPython.Runtime.PythonDictionary greenDictionary = pythonFile.HeightFromProbabilities(stringArray, doubleArray, doubleArray.Length, greenCircuit.DimensionString, useLog);

            QuantumImageHelper.GetProbabilityArrays(simulator.GetProbabilities(blueCircuit), blueCircuit.NumberOfQubits, ref doubleArray, ref stringArray);
            IronPython.Runtime.PythonDictionary blueDictionary = pythonFile.HeightFromProbabilities(stringArray, doubleArray, doubleArray.Length, blueCircuit.DimensionString, useLog);

            return(QuantumImageHelper.CalculateColorTexture(redDictionary, greenDictionary, blueDictionary, redCircuit.DimensionString));
        }
コード例 #4
0
        IronPython.Runtime.PythonDictionary getBlurDictionaryFromData(out string heightDimensions, double[,] imageData, float rotation, bool useLog = false)
        {
            //dynamic pythonHelper = PythonFile.QuantumBlurHelper("Helper");
            blurHelper.SetHeights(imageData, imageData.GetLength(0), imageData.GetLength(1), useLog);
            blurHelper.ApplyPartialX(rotation);

            dynamic circuit        = blurHelper.GetCircuit();
            int     numberofQubits = circuit.num_qubits;

            heightDimensions = circuit.name;


            QuantumCircuit       quantumCircuit = QuantumImageHelper.ParseCircuit(circuit.data, numberofQubits);
            MicroQiskitSimulator simulator      = new MicroQiskitSimulator();

            double[] doubleArray = new double[0];
            string[] stringArray = new string[0];

            QuantumImageHelper.GetProbabilityArrays(simulator.GetProbabilities(quantumCircuit), numberofQubits, ref doubleArray, ref stringArray);
            IronPython.Runtime.PythonDictionary dictionary = pythonFile.HeightFromProbabilities(stringArray, doubleArray, doubleArray.Length, heightDimensions, useLog);

            return(dictionary);
        }