/// <summary> /// Constructs a quantum circuit representing an image for a specific color channel. /// </summary> /// <param name="inputTexture">The texture from which a circuit is constructed</param> /// <param name="useLog">If logarithmic encoding should be used for the picture</param> /// <param name="colorChannel">The color channel (of the texture) which will be used to generate the image</param> /// <returns></returns> public QuantumCircuit GetCircuit(Texture2D inputTexture, bool useLog = false, ColorChannel colorChannel = ColorChannel.R) { //TODO optimize to get 3 channels directly double[,] imageData; switch (colorChannel) { case ColorChannel.R: imageData = QuantumImageHelper.GetRedHeightArray(inputTexture); break; case ColorChannel.G: imageData = QuantumImageHelper.GetGreenHeightArray(inputTexture); break; case ColorChannel.B: imageData = QuantumImageHelper.GetBlueHeightArray(inputTexture); break; case ColorChannel.A: imageData = QuantumImageHelper.GetAlphaHeightArray(inputTexture); break; default: imageData = QuantumImageHelper.GetGreyHeighArray(inputTexture); break; } return(GetCircuit(imageData, useLog)); }
/// <summary> /// Using the quantum teleportation algorithm to mix 2 images. /// Kind of using teleportation to swap placed between the 2 images. /// Teleportation progress of 0 means no teleportation, Teleportation progress of 1 means the teleportation finished. /// And Teleportation progress of 0.5 means it is right in the middle. /// </summary> /// <param name="inputTexture">The first image which should be mixed.</param> /// <param name="inputTexture2">The second image which should be mixed.</param> /// <param name="teleportationProgress">How far the teleportation has progressed. 0 Not at all, 0.5 in the middle, 1 finished. Can take on any value between 0 and 1</param> /// <returns></returns> public Texture2D TeleportTexturesGrey(Texture2D inputTexture, Texture2D inputTexture2, double teleportationProgress) { string heightDimensions; Texture2D OutputTexture = new Texture2D(2, 2); double[,] imageData = QuantumImageHelper.GetGreyHeighArray(inputTexture); double[,] imageData2 = QuantumImageHelper.GetGreyHeighArray(inputTexture2); IronPython.Runtime.PythonDictionary greyDictionary = getTeleportDictionaryFromData(out heightDimensions, imageData, imageData2, teleportationProgress); OutputTexture = QuantumImageHelper.CalculateGreyTexture(greyDictionary, heightDimensions); return(OutputTexture); }
/// <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> /// <returns></returns> public Texture2D CreateBlurTextureGrey(Texture2D inputTexture, float rotation, bool useLog = false, bool useDifferentDecoding = false) { Texture2D OutputTexture; double[,] imageData = QuantumImageHelper.GetGreyHeighArray(inputTexture); QuantumCircuit quantumCircuit = getBlurCircuitFromData(imageData, rotation, useLog); if (useDifferentDecoding) { useLog = !useLog; } OutputTexture = GetGreyTexture(quantumCircuit, useLog); return(OutputTexture); }