Exemplo n.º 1
0
    /// <summary>
    /// Process analysis result, downscaling and post-processing it, preparing the texture to be written to the grid
    /// </summary>
    /// <param name="analysisResult">Analysis result texture</param>
    /// <returns></returns>
    private Texture2D ProcessAnalysisResult(Texture2D analysisResult)
    {
        //Downscale the analysis result
        TextureScale.Point(analysisResult, 64, 64);

        //string folder = @"D:\GitRepo\PublicParts\PP_AI_Studies\temp_en\helpers\";
        //ImageReadWrite.SaveImage2Path(analysisResult, folder + "p2pdownscaledOutput");

        //Create new texture with the same size as the original grid
        Texture2D resultGridTexture = new Texture2D(Size.x, Size.z);

        //Write result to texture
        for (int i = 0; i < resultGridTexture.width; i++)
        {
            for (int j = 0; j < resultGridTexture.height; j++)
            {
                int x = i;
                int y = analysisResult.height - resultGridTexture.height + j;
                resultGridTexture.SetPixel(i, j, analysisResult.GetPixel(x, y));
            }
        }
        resultGridTexture.Apply();
        //ImageReadWrite.SaveImage2Path(resultGridTexture, folder + "p2pcroppedOutput");

        //Return post-processed texture
        return(PP_ImageProcessing.PostProcessImageFromTexture(resultGridTexture));
    }
    /// <summary>
    /// Process analysis result, downscaling and post-processing it, preparing the texture to be written to the grid
    /// </summary>
    /// <param name="analysisResult">Analysis result texture</param>
    /// <returns></returns>
    private Texture2D ProcessAnalysisResult(Texture2D analysisResult)
    {
        //Downscale the analysis result
        TextureScale.Point(analysisResult, 64, 64);

        //Create new texture with the same size as the original grid
        Texture2D resultGridTexture = new Texture2D(_gridSize.x, _gridSize.z);

        //Write result to texture
        for (int i = 0; i < resultGridTexture.width; i++)
        {
            for (int j = 0; j < resultGridTexture.height; j++)
            {
                int x = i;
                int y = analysisResult.height - resultGridTexture.height + j + 1;
                resultGridTexture.SetPixel(i, j, analysisResult.GetPixel(x, y));
            }
        }
        resultGridTexture.Apply();

        //Return post-processed texture
        return(PP_ImageProcessing.PostProcessImageFromTexture(resultGridTexture));
    }