calling a plugin from imagej java program - imagej

I am writing a program in java that calls an imagej plugin. I've done it successfully for "Analyze Particles..." but now I want to do it for "Color Threshold...". For the first one I was simply converting a macro and the parameters were defined and so just worked. But now I am trying to do it from scratch and I can't find any documentation that describes the parameters for color threshold. I have looked thru the imagej source (1.53) and can't find where the parameters are parsed. The code I am using is
IJ.run(ip1, "Color Threshold...", "Y=0-211 U=118-255 V=0-255 [White} [YUV} ");

Related

Where to find code performing filter in gimp codebase?

I was trying to find code performing https://docs.gimp.org/2.10/de/gimp-filter-snn-mean.html
in gimp codebase, but i am able to find only something looking like UI code (not actual math).
I want to peek at this code , my goal is to recreate this filter in python to implement image-processing-pieline designed by my colegue-artist in GIMP.
Operations like filters are defined in separate repository:
https://gitlab.gnome.org/GNOME/gegl
this particular filter is defined here:
https://gitlab.gnome.org/GNOME/gegl/-/blob/master/operations/common/snn-mean.c

How do I convert .bin code property graph to json?

How can I convert a code property graph(cpg) obtained from joern (https://joern.io/) from .bin format to .json format for feeding it to a graph machine learning library for classification.
Note: CPG = AST + Control Flow Graph + Program Dependency Graph
Task: Machine Learning on Source Code.
You can use scala script 'graph-for-funcs.sc' which is included in the joern scripts directory. However you need to redirect the output in order to store it in file (since the output goes to stdout by default).
I made a custom script to do so.

saving roi in imageJ without prompt window

When I try to save a roi in imagej using the code below, a window prompts to save the roi. However, I want to save the roi programmatically so that I can do it for several different files. How can I avoid the prompt window and how can give each roi a specific name (the whole file is saved with the name RoiSet which contain several roi that each should have a different name I choose)?
rm.runCommand("Save", IJ.getDirectory(r"path to my folder") + "RoiSet.zip")
The issue is that IJ.getDirectory(String) returns null, so your path becomes nullRoiSet.zip, which ImageJ thinks is not a valid path, and therefore it prompts with a dialog box.
You do not need the IJ.getDirectory call here; just pass r"path to my folder\RoiSet.zip" directly and it should work without popping any dialogs.
It looks like you are not using the macro language, which might make things a tad more difficult, but I'm not an expert by any means, so take that assumption with a grain of salt. If you do decide to switch and use the macro language, you can simply wrap your code in the batch mode function like so:
setBatchMode(true);
example code here;
setBatchMode(false);
As for saving, the macro language uses the saveAs() function, which takes file type and save path + title of the file as arguments. If you want more info about, or help writing in, the macro language, let me know and we can likely put something together rather quickly.

How to change the default image viewer in SimpleITK

I am using the SImpleITK and ipython notebook for image processing and as we know imagej is the default image viewer in simpleitk. But the type of image i am using is .mha and .mha is not supported by imagej. For this I have to use fiji or imagej2.
I have tried to make fiji as a default image viewer according to the instruction mentioned in simpleitk FAQs but did not get success and show the following message:
I want to know what mistake I am doing .
How to make Fiji or imagej2 as a default image viewer for all types of images when I work with simpleitk and ipython notebook.
Thanks.
Looks to me like you still have ImageJ in your STIK_SHOW_COMMAND variable which is not found in your fiji folder.
Read the instructions again. I assume you did not follow them well enough. Your variable should contain the new image viewer and no ImageJ in a different folder.
Try to change the extension of the file with the system variable SITK_SHOW_EXTENSION and try to provide the command to the visualisation software with SITK_SHOW_COMMAND.
In my .bash_profile I have:
export SITK_SHOW_COMMAND='itksnap'
Other instructions can be obtained with ?sitk.Show() .
Try changing the "%F" to "%f". It is case sensitive. Or actually, you can just leave it off. If there is no "%f" it will just put the file name at the end of the command line.
Also, you can use SimpleITK/ImageJ to view MHA files. SimpleITK actually writes out a Nifti file by default when Show is called, regardless of the input image.

What is the best way to print a Gtk.Widget to the printer?

I have a couple of (mostly) text widgets that I would like to render to a printer through a standard "Print..." menu option. One widget is a Mono.TextEditor document, and the other is a Gtk.TextView.
I'm looking for a pretty basic print for now, which might wrap long lines, and add page numbers. Do I need to code all of this myself somehow?
If you have pointers, that would be great, especially if they were in C#.
For line wrap and justification, one can use pango Layout
options, as described for Python at pygtk/class-pangolayout or for C at pango/pango-Layout-Objects. See functions pango_layout_set_wrap() and pango_layout_set_justify().
Also see the example-code routines begin_print, do_page_setup, and do_print in file pygtk-demo/demos/print_editor.py, if you have installed pygtk on your system. (On my system, the full path to directory of Python Gtk demo files currently is /usr/share/doc/pygtk2-2.17.0/examples/pygtk-demo/demos)
For printer setup dialog, see gtk-High-level-Printing-API for C, or class-gtkprintoperation for Python.

Resources