text labels on moving objects in movies

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

text labels on moving objects in movies

Greta Weiss
I'd like to put text labels (which change with different stages of the filmed activity) and arrows which move with a moving object in a movie.  Does anyone know of a plugin that will easily do this?

Many thanks.
Reply | Threaded
Open this post in threaded view
|

Re: text labels on moving objects in movies

Ed Simmons
Hi Greta,

On 03/01/2014 05:37, Greta Weiss wrote:
> I'd like to put text labels (which change with different stages of the filmed
> activity) and arrows which move with a moving object in a movie.  Does
> anyone know of a plugin that will easily do this?
>
> Many thanks.
>
>
I don't know of a plugin that does this, but you could achieve this
easily with a macro.

You could try to record a macro that isolates the region you're
interested in labelling in the images using the macro recorder in IJ,
then edit to get it to run on all frames in the stack.

If you can work out how to locate the object in a selection of the
frames, this can be used to control where the label is placed.

The macro below loops over the results from Analyse Particles, select
the appropriate frame in the image stack, then add a label at a preset
offset from the location of the particle.

you'd need a macro that looks something like:

// label a moving particle macro
// author Ed Simmons ([hidden email])
title = getTitle();// store the title of the original window to enable
us to switch back to it
run("Duplicate...", "title=temp duplicate range = 1-"+nSlices);
selectWindow("temp");
setThreshold(126, 255); // adjust to suit your object
run("Set Measurements...", "  centroid slice limit redirect=None
decimal=0");
run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00
show=Nothing display clear in_situ stack"); // adjust the size and
circularity to control what is found
// don't draw the label right on top of the particle, here is an offset
in x and y
xoffset=5;
yoffset=10;

// select the original image window, it's time to draw some labels.
selectWindow(title);
for(result=1; result<nResults; result++) { //iterate over the results in
the results table
    slice = getResult("Slice",result);
    x = getResult("X",result) + xoffset;
    y = getResult("Y",result) + yoffset;
    setSlice(slice); // select the right slice in the original image
    drawString("My magic floating label",x,y);
}

Try this by saving the macro (attached to this message too) to a text
file and the opening IJ, open mri-stack from the examples, the run the
macro with Plugins->Macros->Edit and choose the text file you saved. You
can then run the macro with the Macros->Run Macro menu item.

Hope that helps...

Best,
Ed


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

labelMovingParticle.txt (1K) Download Attachment