/// <summary>
    /// A placeholder for creating your own image effect. Keep it static this way you can use it for mesh creation
    /// </summary>
    /// <param name="inputTexture">The Texture of which one wants a blurred image</param>
    /// <returns>A texture with your own image effect applied</returns>
    public static Texture2D CalculateMyOwnEffect(Texture2D inputTexture, float parameter1 = 0, float parameter2 = 0, float parameter3 = 0)
    {
        Texture2D outputTexture;

        // Since we do not need python we do not need to intialize the creator and we can use the static functions of the QuantumImageCreator

        //generating the quantum circuits encoding the color channels of the image
        QuantumCircuit red   = QuantumImageCreator.GetCircuitDirect(inputTexture, ColorChannel.R);
        QuantumCircuit green = QuantumImageCreator.GetCircuitDirect(inputTexture, ColorChannel.G);
        QuantumCircuit blue  = QuantumImageCreator.GetCircuitDirect(inputTexture, ColorChannel.B);

        //Add your own quantum circuit manipulation here!
        //You can use the functions in the region "Effects" bellow

        //ApplyHadamar(red,7);
        //ApplyHadamar(green,7);
        //ApplyHadamar(blue,7);

        //ApplyControlledNotToFraction(red,4);
        //ApplyControlledNotToFraction(green,4);
        //ApplyControlledNotToFraction(blue,4);

        //ApplyControledQtoFraction(red, 0.25f);
        //ApplyControledQtoFraction(green, 0.25f);
        //ApplyControledQtoFraction(blue, 0.25f);

        //Generating the texture after the quantum circuits were modified.
        outputTexture = QuantumImageCreator.GetColoreTextureDirect(red, green, blue, inputTexture.width, inputTexture.height);

        return(outputTexture);
    }
示例#2
0
    //gets called when the job is finished
    void finishJob()
    {
        Debug.Log("Job finished");
        //Creating a texture with the calculated probabilities
        Output = QuantumImageCreator.GetGreyTextureDirect(myJob.Probabilities, Input.width, Input.height, myJob.Circuit.OriginalSum);
        //Setting the new texture to the image on screen
        TargetImage.texture = Output;

        //Hiding Loading Indicator
        LoadingIndicator.SetActive(false);
    }
示例#3
0
    public void ConstructOutput()
    {
        //We need a QiskitSimulator since it can not only run qiskit but also interpret the output from qiskit
        QiskitSimulator simulator = new QiskitSimulator();

        //Preparing the array where the probabilities are stored on
        double[] returnValue = new double[MathHelper.IntegerPower(2, 16)];

        //Here we use the ability from the simulator to read the proabilities from the qiskit output string into our double array
        simulator.ReadProbabilities(ref returnValue, SingleFile.text, Normalization, RecalculateNormalization);

        //We now interpret the probabilities as an image to visualize them
        Output = QuantumImageCreator.GetGreyTextureDirect(returnValue, Dimension, Dimension);
        TargetImage.texture = Output;
    }
示例#4
0
    //Doing the work. Creates a new job and runs it.
    void prepareAndStartJob()
    {
        //Showing Loading Indicator
        LoadingIndicator.SetActive(true);

        //First create a new simulatejob to run this on a seperate thread
        myJob = new SimulateJob();
        //Now set the "simulator" to the QiskitSimulator. (If UseReal is set to true, a real backend is used, and your Token needs to be provided).
        myJob.Simulator = new QiskitSimulator(1000, UseReal, Token);
        //Creating a circuit from the red channel of the provided texture (for black and white image any of the 3 color channels is ok).
        myJob.Circuit = QuantumImageCreator.GetCircuitDirect(Input, ColorChannel.R);
        //applying additional manipulation to the circuit
        applyPartialQ(myJob.Circuit, Rotation);
        //run the job, meaning start the simulation (or the call to the backend)
        myJob.Start();
    }
    /// <summary>
    /// Creating an image which is a mixture between Input Texture 1 and Input Texture 2.
    /// Using teleportation algorithm. Teleport percentage 0 means that it is Texture 1, percentage 1 means it is Texture 2.
    /// Having percentage 0.5 means it is halfway between both images.
    /// The images should have the same size.
    /// </summary>
    public void Teleport()
    {
        if (creator == null || RefreshCreator)
        {
            creator = new QuantumImageCreator();
        }

        if (ColoredImage)
        {
            OutputTexture = creator.TeleportTexturesColoredPartByPart(InputTexture1, InputTexture2, TeleportPercentage);
        }
        else
        {
            OutputTexture = creator.TeleportTexturesGreyPartByPart(InputTexture1, InputTexture2, TeleportPercentage);
        }
    }
    /// <summary>
    /// Creating a blurred image of the Input Texture and safe it to the Output Texture.
    /// Rotation should be between 0 and 1 where 0 is no blur and 1 is maximum blur.
    /// </summary>
    public void CreateBlur()
    {
        if (creator == null || RefreshCreator)
        {
            creator = new QuantumImageCreator();
        }

        bool differentDecoding = !UseLogarithmicEncoding && UseOnlyLogarithmicDecoding;

        if (ColoredImage)
        {
            OutputTexture = creator.CreateBlurTextureColor(InputTexture1, Rotation * Mathf.PI, UseLogarithmicEncoding, differentDecoding);
        }
        else
        {
            OutputTexture = creator.CreateBlurTextureGrey(InputTexture1, Rotation * Mathf.PI, UseLogarithmicEncoding, differentDecoding);
        }
    }
示例#7
0
    //Doing the work. Creates a new job and runs it.
    void prepareAndStartJob()
    {
        if (DeviceName.Length < 5)
        {
            DeviceName = "ibmq_16_melbourne";
        }

        //Showing Loading Indicator
        LoadingIndicator.SetActive(true);

        //First create a new simulatejob to run this on a seperate thread
        myJob = new SimulateJob();
        //Now set the "simulator" to the QiskitSimulator. (If UseReal is set to true, a real backend is used, and your Token needs to be provided).
        myJob.Simulator = new QiskitSimulator(NumberOfShots, UseReal, Token, DeviceName, DontStartPython, UseInternalDevice);
        //Creating a circuit from the red channel of the provided texture (for black and white image any of the 3 color channels is ok).
        myJob.Circuit = QuantumImageCreator.GetCircuitDirect(Input, ColorChannel.R);
        //applying additional manipulation to the circuit
        applyPartialQ(myJob.Circuit, QuantumBlurRotation);
        //run the job, meaning start the simulation (or the call to the backend)
        myJob.Start();
    }
    /// <summary>
    /// Produces a blured version of the input texture (using the quantum blur algorithm) directly in unity without the use of python.
    /// Does NOT support logarithmic encoding. Blur effect done by rotation of quantum state representation.
    /// IS A LOT faster than python version, however, the result still has some errors.
    /// </summary>
    /// <param name="inputTexture">The Texture of which one wants a blurred image</param>
    /// <param name="rotation">How strong the blur effect is.</param>
    /// <returns>A blured texture</returns>
    public static Texture2D CalculateUnityBlur(Texture2D inputTexture, float rotation)
    {
        Texture2D outputTexture;

        // Since we do not need python we do not need to intialize the creator
        // and we can use the static functions of the QuantumImageCreator

        //generating the quantum circuits encoding the color channels of the image
        QuantumCircuit red   = QuantumImageCreator.GetCircuitDirect(inputTexture, ColorChannel.R);
        QuantumCircuit green = QuantumImageCreator.GetCircuitDirect(inputTexture, ColorChannel.G);
        QuantumCircuit blue  = QuantumImageCreator.GetCircuitDirect(inputTexture, ColorChannel.B);

        //applying the rotation generating the blur effect
        ApplyPartialQ(red, rotation);
        ApplyPartialQ(green, rotation);
        ApplyPartialQ(blue, rotation);

        //Generating the texture after the quantum circuits were modified.
        outputTexture = QuantumImageCreator.GetColoreTextureDirect(red, green, blue, inputTexture.width, inputTexture.height);

        return(outputTexture);
    }
    /// <summary>
    /// Produces a blured version of the input texture (using the quantum blur algorithm) doing the blur effect directly
    /// Does support logarithmic encoding. Blur effect done by rotation of quantum state representation.
    /// </summary>
    /// <param name="inputTexture">The Texture of which one wants a blurred image</param>
    /// <param name="rotation">How strong the blur effect is.</param>
    /// <param name="logarithmicEncoding">If logarithmic encoding is used or not.</param>
    /// <returns>A blured texture</returns>
    public Texture2D CalculateSimpleBlur(Texture2D inputTexture, float rotation, bool logarithmicEncoding = false)
    {
        Texture2D outputTexture;

        // Getting the helper class to make the rotation this will setup everything needed in python
        QuantumImageCreator creator = new QuantumImageCreator();

        //Transforming the picture into quantum states
        //Getting 1 circuit for each color channel
        QuantumCircuit red   = creator.GetCircuit(inputTexture, logarithmicEncoding, ColorChannel.R);
        QuantumCircuit green = creator.GetCircuit(inputTexture, logarithmicEncoding, ColorChannel.G);
        QuantumCircuit blue  = creator.GetCircuit(inputTexture, logarithmicEncoding, ColorChannel.B);

        //Applying the rotation (generating the blur). This is the image effect.
        ApplyPartialQ(red, rotation);
        ApplyPartialQ(green, rotation);
        ApplyPartialQ(blue, rotation);

        //Calculating the colored output texture from the quantum circuits for the 3 channels
        outputTexture = creator.GetColoreTextureFast(red, blue, green, logarithmicEncoding);

        return(outputTexture);
    }
示例#10
0
    public void ConstructOutputCombined()
    {
        //Preparing an array of strings to give the simulator
        string[] files = new string[MultipleFiles.Length];
        for (int i = 0; i < MultipleFiles.Length; i++)
        {
            files[i] = MultipleFiles[i].text;
        }

        //We need a QiskitSimulator since it can not only run qiskit but also interpret the output from qiskit
        QiskitSimulator simulator = new QiskitSimulator();

        //Preparing the array where the probabilities are stored on
        double[] returnValue = new double[MathHelper.IntegerPower(2, 16)];

        //Here we use the ability from the simulator to read the proabilities from the qiskit output strings into our double array
        simulator.ReadProbabilities(ref returnValue, files, Normalization, RecalculateNormalization);


        //We now interpret the probabilities as an image to visualize them
        Output = QuantumImageCreator.GetGreyTextureDirect(returnValue, Dimension, Dimension);
        TargetImage.texture = Output;
    }