There are two potential culprits that could explain the difference you see.
- The conversion from a linear index to an RGB colorspace
- The save/load using a graphical image file format.
I would start with suspect 1 (conversion to/from RGB) by bypassing the file save/load.
>> mImRGB = ind2rgb(mIm,jet(128));
>> smag22 = rgb2ind(mImRGB,jet(128));
If the similarity is nonzero, then the problem is with the RGB mapping. Keep in mind that the rgb2ind is not a simple mapping of (RGB) -> linear index, as it can introduce spatial effects such as dithering as well quantization artifacts. It is optimized for visual data. You may eliminate some of that by using coarser colormap (e.g. jet(64)) but you will also lose dynamic range by doing so.
If you can give up the colorization process and save a monochrome image, it could potentially eliminate the issue altogether.
You may also want to inspect the difference image between mIm and smag22, and the maximum norm of that difference.
It could be a small difference of 1 pixel shade value - and it's up to to decide whether it's significant or not.
Lastly, as a general rule, graphic image formats are not meant to be used as precise numerical storage containers, but rather optimized for visual representation. You should make sure the format you choose is not lossy (i.e introduce compression). You may save your STFT as a graphic image only for visualization purposes. For a true precise storage, I would opt to use a mat file or any other binary