ThreeB 1.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

Classes | Functions
Classes related to the ImageJ Plugin

## Classes
class | ClassicGlow
| Plugin implementing the classic glow/hot LUT which seems to be missing from ImageJ. More...
class | LoadTestData
| Plugin class to load the standard test data from the JAR file. More...
class | JNIUserInterface
| 3B User interface for the Java plugin. More...
class | SPair
| Utility class to hold a pair of strings. More...
class | Util
| Utility calss to hold a number of handy static functions. More...
class | three_B
| ImageJ plugin class. More...
class | AdvancedDialog
| Control panel which basically presents the .cfg file in a large edit box along with additional necessary things (frame range and pixel size). More...
class | ThreeBDialog
| Dialog box for starting 3B The dialog highlights bad things in red. More...
class | Spot
| Basic spot class, simply contains coordinates. More...
class | SomethingChanges
| Listener class which triggers a complete redraw. More...
class | FloatSliderWithBox
| This class makes a floating point slider bar with an edit box next to it for more precision. More...
class | CloseButtonListener
| Close button issues a window close event. More...
class | StopButtonListener
| Stop 3B thread. More...
class | ExportButtonListener
| Listener for the export button. More...
class | EControlPanel
| Control panel for running 3B plugin and providing interactive update. More...
class | ThreeBRunner
| This class deals with running the actual 3B code It should be run in a separate thread It will make calls back to a viewer, and accepts termination calls as well. More...
class | ThreeBHelp
| 3B plugin cclass to bring up a basic help window. More...
class | ThreeBLoader
| Plugin class to load up an old 3B run. More...
## Functions
string | get_string (JNIEnv *env, jstring js)
Image< jbyte > | get_local_copy_of_image (JNIEnv *env, jbyteArray data, int rows, int cols)
Image< float > | get_local_copy_of_image (JNIEnv *env, jfloatArray data, int rows, int cols)
JNIEXPORT void JNICALL | Java_ThreeBRunner_call (JNIEnv *env, jobject jthis, jstring cfg, jobjectArray images, jbyteArray mask_data, jint n_images, jint rows, jint cols, jstring file)
static SPair | Util::getFileName (String t)

## Function Documentation

string get_string | ( | JNIEnv * | env,
|  | jstring | js
| ) |  |

Get a local C++ copy of a java string.

Definition at line 141 of file multispot5_jni.cc.

Referenced by Java_ThreeBRunner_call().

    {
        const char* str;

        //Covert the config into a string
        str = env->GetStringUTFChars(js, NULL);

        string stdstring(str);
        env->ReleaseStringUTFChars(js, str);

        return stdstring;
    }

Image<jbyte> get_local_copy_of_image | ( | JNIEnv * | env,
|  | jbyteArray | data,
|  | int | rows,
|  | int | cols
| ) |  |

Get a local C++ copy of an image from a jbyteArray coming from the guts of ImageJ.

Definition at line 157 of file multispot5_jni.cc.

Referenced by Java_ThreeBRunner_call().

    {
        //This takes a copy of the pixels (perhaps)
        jbyte* pix = env->GetByteArrayElements(data, NULL);

        BasicImage<jbyte> pix_im(pix, ImageRef(cols, rows));

        Image<jbyte> im;
        im.copy_from(pix_im);

        //This frees the pixels if copied, or releases a reference
        env->ReleaseByteArrayElements(data,pix, JNI_ABORT);

        return im;
    }

Image<float> get_local_copy_of_image | ( | JNIEnv * | env,
|  | jfloatArray | data,
|  | int | rows,
|  | int | cols
| ) |  |

Get a local C++ copy of an image from a jfloatArray coming from the guts of ImageJ.

Definition at line 175 of file multispot5_jni.cc.

    {
        //This takes a copy of the pixels (perhaps)
        float* pix = env->GetFloatArrayElements(data, NULL);

        BasicImage<float> pix_im(pix, ImageRef(cols, rows));

        Image<float> im;
        im.copy_from(pix_im);

        //This frees the pixels if copied, or releases a reference
        env->ReleaseFloatArrayElements(data,pix, JNI_ABORT);

        return im;
    }

JNIEXPORT void JNICALL Java_ThreeBRunner_call | ( | JNIEnv * | env,
|  | jobject | jthis,
|  | jstring | cfg,
|  | jobjectArray | images,
|  | jbyteArray | mask_data,
|  | jint | n_images,
|  | jint | rows,
|  | jint | cols,
|  | jstring | file
| ) |  |

Run the 3B code.

Definition at line 195 of file multispot5_jni.cc.

References JNIUserInterface::fatal(), get_local_copy_of_image(), get_string(), null_graphics(), and JNIUserInterface::send_message().

    {
        istringstream config(get_string(env, cfg));
        GUI.ParseStream(config);

        JNIUserInterface ui(env, jthis);
        ui.send_message("Initializing...");

        string filename = get_string(env, file);

        //Attmpt to open the file
        ofstream save_spots;
        save_spots.open(filename.c_str());
        int err = errno;

        if(!save_spots.good())
        {
            ui.fatal("failed to open " + filename + ": " + strerror(err));
            return;
        }

        vector<ImageRef> maskir;
        Image<double> maskd;
        {
            Image<jbyte> mask = get_local_copy_of_image(env, mask_data, rows, cols);
            maskd = convert_image(mask);
            for(ImageRef p(-1, 0); p.next(mask.size()); )
                if(mask[p])
                    maskir.push_back(p);
        }

        vector<Image<float> > ims;

        for(int i=0; i < n_images; i++)
        {
            jfloatArray f = static_cast<jfloatArray>(env->GetObjectArrayElement(images, i));
            ims.push_back(preprocess_image(get_local_copy_of_image(env, f, rows, cols)));
            env->DeleteLocalRef(f);
        }

        double mean, variance;
        tie(mean, variance) = mean_and_variance(ims);

        for(unsigned int i=0; i < ims.size(); i++)
                transform(ims[i].begin(), ims[i].end(), ims[i].begin(), bind1st(multiplies<double>(), 1/ sqrt(variance)));

        tie(mean, variance) = mean_and_variance(ims);

        //A sanity check.
        cerr << "Rescaled:\n";
        cerr << "mean = " << mean << endl;
        cerr << "std  = " << sqrt(variance) << endl;
        cerr << "Version 1.1" << endl;

        auto_ptr<FitSpotsGraphics> gr = null_graphics();

        place_and_fit_spots(ims, maskir, maskd, save_spots, *gr, ui);
    }

static SPair Util::getFileName | ( | String | t | ) | `[inline, static, package]`

The a file name for saving and complete path using ImageJ's file open dialog.

Kep re-querying user if the file will be overwritten. Windows already provides the query built in.

Parameters:

  t | Initial file name

Returns:
  filename and full path

Definition at line 80 of file three_B.java.

References SPair::a, and SPair::b.

Referenced by three_B::run().

        {
            //Get a filename to save as, with appropriate warnings for
            //overwriting files.
            String fname, fullname;
            while(true)
            {
                SaveDialog save = new SaveDialog("Save 3B output", t, ".txt");
                fname = save.getFileName();

                fullname = save.getDirectory() + File.separator + fname;

                if(fname == null)
                    break;

                File test = new File(fullname);
                //Windows' open dialog seems to do overwrite confirmation automatically,
                //so there is no need to do it here.
                if(!ij.IJ.isWindows() && test.exists())
                {
                    GenericDialog g = new GenericDialog("Overwrite file?");
                    g.addMessage("The file \"" + fname + "\" already exists. Continue and overwrite?");
                    g.enableYesNoCancel("Yes", "No");
                    g.showDialog();

                    if(g.wasOKed())
                        break;
                    else if(g.wasCanceled())
                    {
                        fname = null;
                        break;
                    }
                }
                else
                    break;
            }

            SPair r = new SPair();
            r.a = fname;
            r.b = fullname;
            return r;
        }