IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
What is your IM version and platform? Please always provide that, since syntax may differ.
Is your After example what is produced from adaptiveThreshold or what you want it to be after changing the colors from the Before image? Which is the result from adaptive threshold and is the Before, the original before using adaptivethreshold?