enter image description hereI have ndarray image=[0 0 0 0 0 4 4 4 0 4 4 4 0 1 4 1] I would to encrypt it using serpent algorithm , so I need to take the ndarray(image) as input to the serpent , how i can do it
Note : I would to read ndarray value like this 0000044404440141 ( without space between item )
any one can help me , in python
CodePudding user response:
Not sure about python but the approach for the same in java can be like using a StringBuilder object and concatenate each integers of the array to the StringBuilder object. like
StringBuilder sb = new StringBuilder();
for(int value: array){
sb.append(value);
}
String param= sb.toString();//if you want it to have as String
Now you can pass param as a string to the method needed.
CodePudding user response:
your can try this if your array is only one dimension:
"".join(str(num) for num in ndarray)
If your array is a nd-array (n>1) of numpy, then you maybe need to flatten it first:
"".join(str(num) for num in ndarray.ravel())