Posted by
Albert Cardona on
Oct 11, 2008; 1:02pm
URL: http://imagej.273.s1.nabble.com/Handle-multiple-bit-depths-tp3694774p3694777.html
Hi Mike,
If you write the plugin a scripting language you can go around this
limitation.
For example in jython:
ip = IJ.getImage().getProcessor()
pix = ip.getPixels()
count = 0
for i in range(len(pix)):
if 200 == pix[i]:
count += 1
print "counted ", count, " pixels of value 200"
Or:
for pixel in IJ.getImage().getProcessor().getPixels():
if 200 == pixel:
count += 1
print "counted ", count, " pixels of value 200"
To edit the pixels you would need to know of what type they are.
Otherwise, setting pix[i] = 12.3 when pixels are a byte[] would fail.
If, on the other hand, you'd like to edit the pixels as well, you can
create a lisp macro in Clojure that will add the proper primitive type
decorations to each type of pixels array, and do so (1) at native speed
and (2) in a single function.
Other scripting languages (like Jython and Javascript) will use
reflection instead (slower, but not unbearable).
Both Jython and Clojure languages are supported for plugins in ImageJ
via Fiji (
http://pacific.mpi-cbg.de ).
The clojure guide for ImageJ:
http://pacific.mpi-cbg.de/wiki/index.php/Clojure_ScriptingOther scripting:
http://pacific.mpi-cbg.de/wiki/index.php/Scripting_Helphttp://pacific.mpi-cbg.de/wiki/index.php/Scripting_comparisonsOther scripting languages supported in Fiji are JRuby, Javascript and
Beanshell:
http://pacific.mpi-cbg.de/wiki/index.php/Category:ScriptingAlbert
--
Albert Cardona
http://www.mcdb.ucla.edu/Research/Hartenstein/acardona