Using Marquee to NaN on an image plot/matrix

Hello, I am looking for a way to NaN certain areas of my image plot using a marquee function. I have used the code snippet : https://www.wavemetrics.com/code-snippet/set-values-marquee-nan#comment-16967 but it does not seem to work on an image plot. I am not sure how to amend it to work for the image plot. I have a 2D matrix as the Z wave, and two 1D waves for the X and Y waves. I want those values to not be included in the function that is being implemented on the matrix, rather than "deleting" the points (so it does not alter my raw data).

Thanks in advance.

 

First, I recommend always working on a copy of the data just to make sure that you can recover from operator errors.

You can use the old Image Processing Procedures that contained a procedure MarqueeToMask().  Once you have a mask you can easily apply it to any image you want using a single MatrixOP operation (see MatrixOP setNans() function).  Alternatively you can also draw an ROI, save that to a wave and again use in MatrixOP to set the NaNs.

I hope this helps,

AG