I can't say much about the percentage failure of adhesion you are looking for and how to get hat value.
The functions for image processing available in Prime can be found in the help. You have to decide if they can do what you are looking for. Generally I think that Prime is not much useful for image processing because of its missing image component which makes is very hard to check the effect of an applied filter, etc.
Concerning the instruction sequence you say yo found somewhere on the net - it sure does not apply to Prime (looks like AI generated).
But i guess you could try to duplicate the actions with primes methods.
Prime does not provide an "image(...)" function, but you can read in an image to a Prime matrix using the "READRGB(...)" function.
Prime does not provide a "Grayscale(...)" function, but you can convert your image to grayscale using the "rgb_to_gray(...)" function.
etc.
The procedure outlined in that sequence may look like this in Prime

Not sure if the result is in any way meaningful to you.
BTW, the multiplication of the threshold value by 255 was done because the greyscale image in Prime is represented by a matrix with numbers running from 0 to 255 (8 bit). Because of the threshold value 0.5 I assumed that the method you had outlined was based on values in the range from 0 to 1.
Prime 10 sheet attached