I have an image in Python embedded in ECL(through the EMBED() function). The image is in the form of a numpy array. How do I return it back to ECL and are there any methods to visualize the image?
I tried returning the numpy array back to ECL but couldn't find the right datatype.
There is no direct way to visualize images in ECL, but you can use the ECL data manipulation tools and efficiency to work with the data extracted from the image.
Let's use the example of a RGB pixel extraction of an image, using embedded python, and then use the data in the ECL code scope. For this example we'll be using the Numpy and Pillow libraries, but you could be using any library you want. Note that is important to have these packages installed on the environment running the platform, not only in your local machine. The Python code will be:
It'll return a translation of the image for the RGB code, describing it pixel by pixel.
Now, we embed it in ECL. Since the data type for return may be difficult to spot at first, we can always use an approach of returning it as STRING and reformatting it later using ECL, since it's a powerful data oriented language. The code would be:
The output of your WU will be a string containing all the data retrieved from the embedded python function:
Notice that Python truncates the results before retrieving the data, you can easily change this behaviour by adding a couple lines of code in the Python scope, such as:
After that, is just a matter of data reformat and transformation so you can use it to serve your purposes.
Hope this helps.