Exemplo n.º 1
0
    public Texture2D CircuitToTexture()
    {
        Texture2D outPutTexture;

        //generating the quantum circuits encoding the color channels of the image

        QuantumCircuit red;

        //QuantumCircuit green;
        //QuantumCircuit blue;


        double[,] imageData = QuantumImageHelper.GetHeightArrayDouble(startTexture, ColorChannel.R);
        if (UseSimpleEncoding)
        {
            red = QuantumImageHelper.ImageToCircuit(imageData);
        }
        else
        {
            red = QuantumImageHelper.HeightToCircuit(imageData);
        }


        Circuit = red;


        red.Gates = Gates;
        //blue.Gates = Gates;
        //green.Gates = Gates;

        double[,] redData;//,  greenData, blueData;

        if (UseSimpleEncoding)
        {
            redData = QuantumImageHelper.CircuitToImage(red, size, size, RenormalizeImage);
            //greenData = QuantumImageHelper.CircuitToImage(green, size, size);
            //blueData = QuantumImageHelper.CircuitToImage(blue, size, size);
        }
        else
        {
            redData = QuantumImageHelper.CircuitToHeight2D(red, size, size, RenormalizeImage);
            //greenData = QuantumImageHelper.CircuitToHeight2D(green, size, size);
            //blueData = QuantumImageHelper.CircuitToHeight2D(blue, size, size);
        }

        //outPutTexture = QuantumImageHelper.CalculateColorTexture(redData, greenData, blueData);
        outPutTexture            = QuantumImageHelper.CalculateColorTexture(redData, redData, redData, PaintColor.r, PaintColor.g, PaintColor.b);
        outPutTexture.filterMode = FilterMode.Point;
        outPutTexture.wrapMode   = TextureWrapMode.Clamp;
        QiskitString             = red.GetQiskitString(true);

        return(outPutTexture);
    }
Exemplo n.º 2
0
    public Texture2D ApplyGates(Texture2D InputTexture1)
    {
        Texture2D outPutTexture;


        //generating the quantum circuits encoding the color channels of the image

        QuantumCircuit red;
        QuantumCircuit green;
        QuantumCircuit blue;

        double[,] imageData = QuantumImageHelper.GetHeightArrayDouble(InputTexture1, ColorChannel.R);
        if (UseSimpleEncoding)
        {
            red = QuantumImageHelper.ImageToCircuit(imageData);
        }
        else
        {
            red = QuantumImageHelper.HeightToCircuit(imageData);
        }

        imageData = QuantumImageHelper.GetHeightArrayDouble(InputTexture1, ColorChannel.G);
        if (UseSimpleEncoding)
        {
            green = QuantumImageHelper.ImageToCircuit(imageData);
        }
        else
        {
            green = QuantumImageHelper.HeightToCircuit(imageData);
        }

        imageData = QuantumImageHelper.GetHeightArrayDouble(InputTexture1, ColorChannel.B);
        if (UseSimpleEncoding)
        {
            blue = QuantumImageHelper.ImageToCircuit(imageData);
        }
        else
        {
            blue = QuantumImageHelper.HeightToCircuit(imageData);
        }

        //QuantumCircuit red = QuantumImageCreator.GetCircuitDirect(InputTexture1, ColorChannel.R);
        //QuantumCircuit green = QuantumImageCreator.GetCircuitDirect(InputTexture1, ColorChannel.G);
        //QuantumCircuit blue = QuantumImageCreator.GetCircuitDirect(InputTexture1, ColorChannel.B);

        red.Gates   = Gates;
        blue.Gates  = Gates;
        green.Gates = Gates;

        double[,] redData, greenData, blueData;

        if (UseSimpleEncoding)
        {
            redData   = QuantumImageHelper.CircuitToImage(red, InputTexture1.width, InputTexture1.height);
            greenData = QuantumImageHelper.CircuitToImage(green, InputTexture1.width, InputTexture1.height);
            blueData  = QuantumImageHelper.CircuitToImage(blue, InputTexture1.width, InputTexture1.height);
        }
        else
        {
            redData   = QuantumImageHelper.CircuitToHeight2D(red, InputTexture1.width, InputTexture1.height);
            greenData = QuantumImageHelper.CircuitToHeight2D(green, InputTexture1.width, InputTexture1.height);
            blueData  = QuantumImageHelper.CircuitToHeight2D(blue, InputTexture1.width, InputTexture1.height);
        }

        outPutTexture = QuantumImageHelper.CalculateColorTexture(redData, greenData, blueData);

        return(outPutTexture);
    }
Exemplo n.º 3
0
    public Texture2D CreateBlur(Texture2D inputeTExture, float rotation)
    {
        Texture2D outPutTexture;


        //generating the quantum circuits encoding the color channels of the image

        QuantumCircuit red;
        QuantumCircuit green;
        QuantumCircuit blue;

        double[,] imageData = QuantumImageHelper.GetHeightArrayDouble(inputeTExture, ColorChannel.R);
        if (UseSimpleEncoding)
        {
            red = QuantumImageHelper.ImageToCircuit(imageData);
        }
        else
        {
            red = QuantumImageHelper.HeightToCircuit(imageData);
        }

        imageData = QuantumImageHelper.GetHeightArrayDouble(inputeTExture, ColorChannel.G);
        if (UseSimpleEncoding)
        {
            green = QuantumImageHelper.ImageToCircuit(imageData);
        }
        else
        {
            green = QuantumImageHelper.HeightToCircuit(imageData);
        }

        imageData = QuantumImageHelper.GetHeightArrayDouble(inputeTExture, ColorChannel.B);
        if (UseSimpleEncoding)
        {
            blue = QuantumImageHelper.ImageToCircuit(imageData);
        }
        else
        {
            blue = QuantumImageHelper.HeightToCircuit(imageData);
        }

        //QuantumCircuit red = QuantumImageCreator.GetCircuitDirect(InputTexture1, ColorChannel.R);
        //QuantumCircuit green = QuantumImageCreator.GetCircuitDirect(InputTexture1, ColorChannel.G);
        //QuantumCircuit blue = QuantumImageCreator.GetCircuitDirect(InputTexture1, ColorChannel.B);

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

        Gates = red.Gates;
        double[,] redData, greenData, blueData;

        if (UseSimpleEncoding)
        {
            redData   = QuantumImageHelper.CircuitToImage(red, inputeTExture.width, inputeTExture.height, RenormalizeImage);
            greenData = QuantumImageHelper.CircuitToImage(green, inputeTExture.width, inputeTExture.height, RenormalizeImage);
            blueData  = QuantumImageHelper.CircuitToImage(blue, inputeTExture.width, inputeTExture.height, RenormalizeImage);
        }
        else
        {
            redData   = QuantumImageHelper.CircuitToHeight2D(red, inputeTExture.width, inputeTExture.height, RenormalizeImage);
            greenData = QuantumImageHelper.CircuitToHeight2D(green, inputeTExture.width, inputeTExture.height, RenormalizeImage);
            blueData  = QuantumImageHelper.CircuitToHeight2D(blue, inputeTExture.width, inputeTExture.height, RenormalizeImage);
        }

        outPutTexture = QuantumImageHelper.CalculateColorTexture(redData, greenData, blueData);
        return(outPutTexture);
    }