Image Noise Detection Using MATLAB
I would implement it differently altogether.
Since applying the Wiener filter is pretty "cheap" I would create an Image called mWienerFilter.
Then:

vNoisePixels = (abs(I -  mMeanImage) &gt; noiseThr);
I(vNoisePixels) = mWienerFilter(vNoisePixels);


That would be the best thing to do in my opinion.