Color Threshold Values not adjusting in Macro, but works fine Manually?

Hello everyone! I am relatively inexperienced when it comes to writing macros and was able to build something using the record function to analyse images for contaminants. I started the process of sharing it with my team members so that they can also run the macro and perform this test, but I am having issues with the macro when it is run on a new computer. For some reason, the color threshold is not adjusting when the macro is run so instead of a white image with a bunch of red spots, I get a black image instead which makes it hard to see all of the other contaminants that were present, but didn’t qualify with a large enough area to be of a concern. I tried running the process manually, and experienced no issues what-so-ever. I even tried building the macro from scratch on their computer only to experience the same issue once it was run on its own (even through the result obtained while using the record function came out right, and I have never experienced this problem myself when I run the same macro on my computer). The first image below is what I am looking to obtain-

The result I get from my co-workers computer is the following-

I have layed out the macros side-by-side to show for comparison (the one on the left is the macro I have used, the one on the right is the one that my co-worker used.

The only thing I could reason is that something is going wrong with the color threshold function when the macro is run, but what exactly is completely beyond me. I would really like to share this capability with the other group members, but until I am able to figure out why I can’t recreate the first result on other computers, I am out of luck with expediting the process for other group members. Any insight/help would be greatly appreciated!

Hi @ChEng.Mac.Newbie

Two things I notice in your screenshots:

  1. Your white background image has inverted LUT. You can change the black background to white, by inverting its LUT: Image > Lookup Tables > Invert LUT

  2. The reason you are getting different numbers in your Results and Summary windows might be because your images are of different sizes. The image with the white background is 1436x1424 pixels and the other one is 1464x1472 pixels. I would suggest to run the same image on both the computers.


Check the Process Binary Options in the two computers if you have the same options set.


Hey Ved,

Thanks for the insight! Couple thoughts about your recommendations-

  1. The fix you recommended worked, though it does not identify the route cause of the issue (why my computer doesn’t need this extra step of inverting the LUT while the other computers do). The recommendation Gabriel suggested did the trick. I very much appreciate your response!

  2. The size of the image is different is something I can explain. These samples are small (maybe 100cm^2 total). Since we place these samples on white sheets and scan them in to create a image fill for analysis, the placement can vary depending on who is prepping the samples to scan. Since multiple samples can be found on each image (to save paper), users go in and select the area they are looking to analyze manually before executing the macro (the samples are boxed into a specific area to make it easier for users to select the proper space). It was easier when we were using colored paper to identify the samples, but this interfered with the analysis because the color was always picked up to some degree by the threshold settings (and it was impossible to set a threshold that eliminated the back ground without sacrificing some loss on what is classified as a containment on the sample itself (some spots no longer counted as failures, giving a skewed result), hence the shift to white paper to avoid that issue. We’re not looking for a perfect process, just something that gives us an indication as to what to expect if were to run certified testing. The total black image just causes confusion when reporting the final results.


That did the trick. The macro is working the same now. Thanks for the suggestion!