/// <summary> /// Using the quantum teleportation algorithm to mix 2 greyscale images. This is A LOT FASTER than the other Teleport method. /// It splits the image into smaller images, which can be progressed way faster and then puts them back together. /// Can sometimes have some slight errors in images with big blocks of black pixels. /// Else it uses the same method 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 TeleportTexturesGreyPartByPart(Texture2D inputTexture, Texture2D inputTexture2, double mixture) { int dimX = 8; int dimY = 8; int width = inputTexture.width; int height = inputTexture.height; if (inputTexture2.width < inputTexture.width || inputTexture2.height < inputTexture.height) { if (inputTexture2.width > inputTexture.width || inputTexture2.height > inputTexture.height) { Debug.LogError("Can't find matching dimension."); return(new Texture2D(width, height)); } else { Debug.LogWarning("Inputtexture 1 is too big only part of it will be used"); width = inputTexture2.width; height = inputTexture2.height; } } else if (inputTexture2.width > inputTexture.width || inputTexture2.height > inputTexture.height) { Debug.LogWarning("Inputtexture 2 is too big only part of it will be used"); } if (width % 8 != 0) { Debug.LogWarning("Width not divisble by 8 sleighly cutting width (by " + width % 8 + ")."); width = width - (width % 8); } if (height % 8 != 0) { Debug.LogWarning("Height not divisble by 8 sleighly cutting width (by " + height % 8 + ")."); height = height - (height % 8); } int totalX = width / dimX; int totalY = height / dimY; int startX = 0; int startY = 0; double[,] imageData = new double[dimX, dimY]; double[,] imageData2 = new double[dimX, dimY]; Texture2D OutputTexture = new Texture2D(width, height); string heightDimensions; IronPython.Runtime.PythonDictionary greyDictionary; for (int i = 0; i < totalX; i++) { for (int j = 0; j < totalY; j++) { double max1 = QuantumImageHelper.FillPartialHeightArray(inputTexture, imageData, ColorChannel.R, startX, startY, dimX, dimY); double max2 = QuantumImageHelper.FillPartialHeightArray(inputTexture2, imageData2, ColorChannel.R, startX, startY, dimX, dimY); greyDictionary = getTeleportDictionaryFromData(out heightDimensions, imageData, imageData2, mixture, (1 - mixture) * max1 + mixture * max2); QuantumImageHelper.FillTextureGrey(greyDictionary, OutputTexture, startX, startY); startY += dimY; startY = startY % width; } startX += dimX; } OutputTexture.Apply(); return(OutputTexture); }