Background Image Script?
 1-20  21-32

Previous
Next
 From:  Michael Gibson
6162.21 In reply to 6162.19 
Hi FDP,

> Now I just have to figure out how to take a modifier for the command (e.g. fork at --num or ++num).

It is possible to pass parameters to a command so that you can have 2 different keyboard shortcuts each of which call the same command but with slightly different behavior.

The Nudge plug-ins do this so they're the best ones to look at for an example:
http://kyticka.webzdarma.cz/3d/moi/#Nudge

You basically put the parameter as a second word in the keyboard shortcut, with a space after the command name, like:
IncrementImage backward

Then inside the command script file, use moi.command.getCommandLineParams() to access those parameters.

Something like this example from the Nudge command:

code:
	var params = moi.command.getCommandLineParams();
	
	if ( params.search( /left/i ) != -1 )
	{
		// The parameters contain the word "left" in it.
		dist = -dist;
	}


- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  FDP
6162.22 In reply to 6162.21 
Thanks Michael!

-FDP
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  FDP
6162.23 In reply to 6162.20 
Hi Michael,

I have dropped the function you gave into the initial script and it did exactly what I had hoped!

I'll try to expand this to match the rest of what I had been going for in the pseudocode example over the next few days. I was also thinking of using the system clock script as a basis for a current frame# display in the bottom right hand corner of the window.

Our of interest, is there any reason why there isn't more of a push to have users add buttons to the GUI for running custom scripts?

I attached the script with the added function to rename curves to match image bg numbers in case anyone else wants to use it.

Regards,
FDP
Attachments:

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
6162.24 In reply to 6162.23 
Hi FDP, I'm glad that naming function worked for you!

> Our of interest, is there any reason why there isn't more of a push to have users add
> buttons to the GUI for running custom scripts?

It's on my "todo" list but so are a zillion other things. Right now I'm still focused on more core functionality, things like custom scripts are definitely useful but they're used by only a small number of advanced users, while core functionality is used by a wide range of users... So that factors into the urgency of which features get attention.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  FDP
6162.25 In reply to 6162.24 
I definitely understand. You are one person - MoI is fantastic and your support on this forum is really top notch, so I'm certainly not trying to complain!

-FDP
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  FDP
6162.26 In reply to 6162.25 
I thought this might be helpful to others - the method I use for getting image sequences out of stacks that are in video format is by using ffmpeg. On Windows the command line parameters are slightly different than linux/OsX, the following example will work if all you want are low-quality jpegs:

ffmpeg -i "Input_Filename.mp4" -f image2 Output_Filename%%5d.jpg

The "%%5d" part is telling ffmpeg to pad the output frame counter to 5 digits, which will make the results compatible with Michael's "IncrementImage" script.

You can use different filetypes, e.g. .mov or .avi for the input file type and .png, etc for the output file type.

Windows builds of ffmpeg can be found here: http://ffmpeg.zeranoe.com/builds/

The precompiled ffmpeg application is found in the bin folder

Incidentally on Linux/OsX the following should be an equivalent command:

ffmpeg -i "Input_Filename.mp4" -f image2 Output_Filename%5d.jpg

-FDP
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
6162.27 In reply to 6162.26 
Thank you FDP.

Is there a good source for CT scan image video (free)?

I see that they use video at:
http://arc-team-open-research.blogspot.com/2012/09/converting-video-of-computed-tomography.html
http://www.oucom.ohiou.edu/dbms-witmer/3D-Visualization.htm

I spent a little time looking at Invesalius, 3DSlicer, and RadiAnt, which use "DICOM."
There are a couple of programs called "img2dcm," code anyway, to convert PNG and/or JPEG to DICOM,
but a person would have to be a software expert to use it.(?) I'll have to try the Python line.

- Brian
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  FDP
6162.28 In reply to 6162.27 
Hi Brian,
DICOM is pretty much the industry standard, and usually consists of a stack of scan images (float) with metadata.

For cross platform, take a look at ImageJ, it's free & powerful with tons of plugins.

On OsX the best program is OsiriX, which is outstanding for volumetric data processing in general.

If you Google " CT stack " or "DICOM data" you should find some examples pretty easily. YouTube also has some examples.

The example I used was from the Wikipedia "Computed Tomography" page :)

-FDP
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  FDP
6162.29 In reply to 6162.28 
Hi Michael,
I was wondering if you might be able to give some advice/help. I integrated the branching you recommended (which works perfectly), but now am trying to make the layers position themselves at a z depth matching the image number. I've stolen what seems like 99% of the right code from the "Nudge" script. I think the problem is with using the "factory.setInput( 0, obj );" where "obj" is an object selected by being unnamed. Here's the snippet:

function SetObjectNames( newname )
{
// Set any unnamed objects to have the given name.

var objects = moi.geometryDatabase.getObjects();

for ( var i = 0; i < objects.length; ++i )
{
var obj = objects.item(i);

// An "unnamed" object will have an empty string as its name property.
if ( obj.name == '' )
obj.name = newname;

// Set the selected object to a Z plane derived from the layer/frame#
// Stolen verbatim from the "nudge" script.
var factory = moi.command.createFactory( 'move' );
factory.setInput( 0, obj );
var axis = 'zaxis';
var dist = 1.0;

// Create 2 points, these will default to 0,0,0.
var basept = moi.vectorMath.createPoint();
var offsetpt = moi.vectorMath.createPoint();

// Set up the offset point.
var dir = moi.view.getCPlane()[axis];
dir.scale( dist );
offsetpt.add( dir );

factory.setInput( 1, basept );
factory.setInput( 2, offsetpt );
factory.commit();

}
}

I've attached the version of the script that the snippet came from which isn't working (v4) as well as the last version that works (v3).

To use the script just call it with "inc" or "dec" as a parameter. I have these hotkeyed to "CTRL +" and "CTRL -" on my keyboard, and version 3 works very nicely!

-FDP

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
6162.30 In reply to 6162.29 
Hi FDP,

> I think the problem is with using the "factory.setInput( 0, obj );" where "obj" is an object
> selected by being unnamed. Here's the snippet:

From my first quick look, it looks like you need to make an "object list" to put into the factory's input index 0, not just an object.

Someday I'd like to tune this up so that the factory system could take either a single object or an object list in that slot but right now it usually only expects to see object lists there for factories that can take more than one object for their operations.

So try something like this - above your function SetObjectNames put in this function:

code:
function WrapWithObjectList( obj )
{
	// Create an object list and fill it with the given object. Some things require an object
	// list for input and can't handle a single object instead right now.
	var list = moi.geometryDatabase.createObjectList();
	list.addObject( obj );
	return list;
}


And then inside your function change:
code:
factory.setInput( 0, obj );


to instead be:

code:
factory.setInput( 0, WrapWithObjectList(obj) );


At some point I also expect to make some more friendly direct calls for things like copying and transforming objects and making lines and things like that, rather than only having the factory type methods... The factory mechanism works well for interactive commands since you can hook things like a pointpicker into a factory input and then that drives updates to that point value, but it's not very convenient when you just want to do a simple transform like you're doing here.

Let me know if you're still running into problems after that change and I'll take a close look.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  FDP
6162.31 In reply to 6162.30 
Thanks Michael! This has gotten to be pretty awesome pretty quickly. I've added in the layer movement and set it up so it moves layers forwards or backwards along with the image sequence position (might get really slow with a large amount of curves). This means that whatever image in the sequence is selected will always be at Z = 0.

Attached is the latest version of the script. Now I just need to figure out how to hide layers after they are renamed (assuming I can just use obj.hidden = true;) , as I think this would be helpful as an option!

-FDP
Attachments:

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  Michael Gibson
6162.32 In reply to 6162.31 
Hi FDP, you're welcome!

> (assuming I can just use obj.hidden = true;)

Yup, if you have an object you set it to be hidden by doing: obj.hidden = true.

Also if you have an object list you can set all objects in the list to be hidden by: objlist.setProperty( 'hidden', true );

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All

 

 
 
Show messages:  1-20  21-32