How to threshold an image only within a ROI/selection using ImageJ

Dear all,

I want to use ImageJ to create templates for template-matching using normalized cross-correlation. For this I want to threshold a region of the template and set it 0, so that it will not contribute to the cross-correlation. I want to do this, because the appearance inside these regions can change significantly in the image that I will match with this template and therefore want to avoid spurious correlations.

In this image you can see an example of what a “raw” template can look like (without thresholding).

To generate the final template I would like to threshold only within the marked region and set the values above the threshold to 0. E.g. something like this, but only within the selected region:

Specifically, I do not want to threshold the brighter vertical image-area to the right of the selected region. I therefore have to threshold only within the marked region, since the vertical region is brighter than the features I am interested inside the selection.

However, I do not know how to do achieve this and therefore help would be much appreciated!

Dear Michael,

Try Edit>Clear Outside. Anything outside the ROI should turn black and you can then threshold the bars in the ROI.




Thank you @MatthieuV!

In combination with the explanation here I was able to do what I wanted.


1 Like