documents:120206pyip_cooking:python_imagej_cookbook
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
documents:120206pyip_cooking:python_imagej_cookbook [2024/10/08 17:45] – [Accessing multiple files to load image sequences] kota | documents:120206pyip_cooking:python_imagej_cookbook [2025/05/21 03:59] (current) – kota | ||
---|---|---|---|
Line 3: | Line 3: | ||
This page was last edited at: ~~LASTMOD~~ | This page was last edited at: ~~LASTMOD~~ | ||
- | For learning image processing using Fiji and Jython scripting, go to excellent tutorials written by Albert Cardona, such as [[https:// | + | For learning image processing using Fiji and Jython scripting, go to excellent tutorials written by Albert Cardona, such as [[https:// |
+ | |||
+ | This page is like a cookbook: there are no details about how to do programming, | ||
+ | |||
+ | **HOW TO USE**: This page is not intended for reading from top to bottom. Just search this page (e.g. command-f or ctrl-f) for the term you are looking for. This cookbook is a single page, so this allows the full search of the whole book (a single-page " | ||
- | This page is like a cookbook: there are no details about how to do programming, | ||
Other resources: | Other resources: | ||
Line 11: | Line 14: | ||
[[https:// | [[https:// | ||
===== Jython Interpreter ===== | ===== Jython Interpreter ===== | ||
- | A way to run jython | + | A way to run a Jython |
<code python> | <code python> | ||
#simply do | #simply do | ||
Line 25: | Line 28: | ||
</ | </ | ||
- | Of course you could do this by clicking ' | + | Of course, you could do this by clicking ' |
- | ===== Singed/Unsigned value conversions ===== | + | ===== Signed/Unsigned value conversions ===== |
- | Java normally uses signed values but images are generally not signed (for 8 bit, 16 bit images). For this reason, when you work with images as an single array, there will be some need for conversion between signed | + | Java normally uses signed values, but images are generally not signed (for 8-bit and 16-bit images). For this reason, when you work with images as a single array, there will be some need for conversion between signed |
- | <code python linenums:1> | + | <Code:py linenums> |
from ij import IJ | from ij import IJ | ||
import struct | import struct | ||
Line 43: | Line 46: | ||
pix = map(s2u8bit, | pix = map(s2u8bit, | ||
- | #check that the conversion worked. | + | # Check that the conversion worked. |
- | # this example was made for binary image, to print only values 255 | + | # This example was made for a binary image, to print only values 255 |
for j in range(len(pix)): | for j in range(len(pix)): | ||
curval = pix[j] | curval = pix[j] | ||
Line 52: | Line 55: | ||
else: | else: | ||
print curval | print curval | ||
- | </code> | + | </Code> |
- | ===== Singed/Unsigned value conversions with bitwise & operator ===== | + | ===== Signed/Unsigned value conversions with bitwise & operator ===== |
- | Here is another example of going back and forth between signed and unsigned values. The scripts load " | + | Here is another example of going back and forth between signed and unsigned values. The scripts load " |
- | <code python linenums:1> | + | <code:python linenums> |
from ij import IJ | from ij import IJ | ||
import jarray | import jarray | ||
Line 88: | Line 91: | ||
Same processing could be also done by replacing L7 to L23 by | Same processing could be also done by replacing L7 to L23 by | ||
- | <code python | + | <code python |
for j in range(imp.getHeight()): | for j in range(imp.getHeight()): | ||
Line 116: | Line 119: | ||
==== Getting path to a file interactively ==== | ==== Getting path to a file interactively ==== | ||
- | <code python | + | <Code python |
from ij.io import OpenDialog | from ij.io import OpenDialog | ||
+ | |||
op = OpenDialog(" | op = OpenDialog(" | ||
print op.getDirectory()+ op.getFileName() | print op.getDirectory()+ op.getFileName() | ||
- | </code> | + | </Code> |
- | ==== Getting the directory where the curently | + | ==== Getting the directory where the currently |
<code python: | <code python: | ||
from ij import IJ | from ij import IJ | ||
Line 130: | Line 134: | ||
</ | </ | ||
- | ... can also be done by '' | + | ... can also be done by '' |
Be careful not to mix with the usage of '' | Be careful not to mix with the usage of '' |
documents/120206pyip_cooking/python_imagej_cookbook.1728409503.txt.gz · Last modified: 2024/10/08 17:45 by kota