Result from using imp.dupicate() in Jython changed

Hi I am trying to duplicate a selected area of a stack from Jython script

It used to be that

imp = IJ.getImage()
imp.setRoi(1000, 1000, 200, 200)
imp2=imp.duplicate()
imp2.show()

would do the job
after update (to 1.5 version) this script duplicates the whole image instead of just selected area.

how can I duplicate a selected area now. Is there a glitch in implementation of duplicate() method

Thanks so much in advance!!

Use imp.crop(“stack”). You will need to be running ImageJ 1.52o or later.

1 Like

Thanks so much!
Will try.

So far I had to use this (below) it worked but kind of looks clumsy:

imp = IJ.getImage()
imp_stack=imp.getStack()
croppedstack = imp_stack.crop(5000,3000,0,500,500,66)
imp2=ImagePlus("bla",croppedstack)
imp2.show()

You can also crop a stack using

imp2 = new Duplicator().run(imp);
1 Like