How to get rid of the ROI selected boundary on the image in fiji macro?

I masked the image with the border defined in ROI and I saved the image as tif and the yellow ROI border of the image is already saved with the image. When I open the image again in fiji, that border appears with the image. Like this:
image
I need to produce histogram of the image but I noticed when the yellow border is on the image, the result of the histogram is zero all and once I click on the border and get rid of the border, the result of histogram is non zero and makes sense. As I need to do these steps in imagej macro, I need to write a piece of code to get rid of that yellow border before producing histogram. I tried to record what I did by hand but did not help.
I also tried to “deselect” from ROI. It was deselected from ROI but not from the image.
I am not sure if there is a way I can attach the main image instead of the screenshot so that you can see the real image with its border.

Hi Zeynab_Mousavi,

There are two ways to do this as follows,

  1. If you want to retain the border in your real image, once you open the image just before you measure histogram you can use this option, Edit>Selection>Select none. This same command can be added in the macro as follows before your histogram line.
    run(“Select None”);

  2. If you want to retain just the selection from your real image you can duplicate the selected region and save it as a separate image before you do draw histogram.

Hope this helps!!!

Regards,
Lakshmi