Calling the Image Threshold panel from code
chozo
The question is very simple: I want to do the same as clicking Image => Image Threshold, but from code. I have created an image plot and call:
DoIgorMenu "Image" "Image Threshold"
...which summons the panel but DOES NOT automatically overlay the threshold result over the image in the graph (live mode), which usually happens when the panel is called manually. How can this be achieved? Is there another way to call this panel (or any of the other image processing tools) and maybe associate it with a certain graph? I am using Igor 9.06 on Windows 10.
The short answer is probably NO. The image menu and the associated dialogs were not designed to support changes from procedure execution.
The image menu becomes active when there is an image in the top window. The various dialogs change when the top window changes. Some dialog properties are stored in the private data folders and others may depend on the type of top image (e.g., gray vs color options). The only command line that can get you part of the way towards the desired control is indeed DoIgorMenu (which you evidently know about).
Please note that data objects in the associated Private data folders are strictly private. Modifying any of these objects could lead to unpredictable results.
AG
December 13, 2024 at 10:13 am - Permalink
AG, thank you for the answer. So there is some magic sauce which cannot be recreated with DoIgorMenu I suppose. I was just wondering why from the same starting conditions actually pressing on the menu entry and using above DoIgorMenu command, e.g., executed from the command line does not lead to the same outcome. I will try to look into other options then, e.g., summoning the old threshold procedure from Image Processing.
December 13, 2024 at 10:03 pm - Permalink
@chozo: I think your expectation is reasonable. You're not trying to control the dialog from code, you're just calling it and expect it to work the same way when called with DoIgorMenu as when you select the menu item manually.
I stepped through the code that executes and I think the problem is likely that the threshold overlay image is appended to the graph, but the graph isn't redrawn to reflect that. This isn't my code so I might not fully understand what's happening.
I've created an internal bug report to investigate this. It might be impractical to fix, but I think it's something we should look into.
December 14, 2024 at 11:47 am - Permalink
Thank you. Yes, I noticed that no further code execution happens as soon as the panel appears, even if the call is in the middle of a function. I tried to sneak in DoUpdate calls somewhere, but was not successful. It would be great if this could be fixed, which would spare me from the work of writing a custom panel myself.
December 15, 2024 at 05:30 pm - Permalink
You might try DoIgorMenu() from the command line using Execute/P. If you need this to happen in the middle of something, you might need to split your function in two, the first piece executing up to Execute/P "DoIgorMenu..." A second Execute/P would invoke a function that is the second half of your present function.
Maybe...
December 16, 2024 at 09:28 am - Permalink
John, that's indeed the first thing I tried out. :-) Unfortunately, Execute/P does not help with the main issue of the missing graph update here. I actually like that the function execution is halted when the Image Threshold panel is in action. Makes it easy to line up post-processing code such as renaming the output and killing the graph.
December 17, 2024 at 02:29 am - Permalink