documents:120206pyip_cooking:python_imagej_cookbook
                Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| documents:120206pyip_cooking:python_imagej_cookbook [2025/10/05 22:36] – [Creating floating point processor image] kota | documents:120206pyip_cooking:python_imagej_cookbook [2025/10/05 22:53] (current) – [Converting Java array types] kota | ||
|---|---|---|---|
| Line 821: | Line 821: | ||
| ==== Converting Java array types ==== | ==== Converting Java array types ==== | ||
| - | Sometimes we need to convert the type of Java array e.g. double[] to int[]. | + | Sometimes we need to convert the type of Java array e.g. double[] to int[]. | 
| < | < | ||
| + | from ij import IJ | ||
| from ij.process import StackStatistics | from ij.process import StackStatistics | ||
| import jarray | import jarray | ||
| + | imp = IJ.getImage() #stack | ||
| stackstats = StackStatistics(imp) | stackstats = StackStatistics(imp) | ||
| - | histD = stackstats.histogram() | + | histD = stackstats.histogram() | 
| - | hist = jarray.zeros(len(histD), ' | + | print(type(histD[0])) | 
| - | for i in range(len(histD)): | + | |
| - | hist[i] = int(histD[i]) | + | hist = map(int, histD) | 
| + | histInt = jarray.array(hist, ' | ||
| + | print(type(histInt[0])) #Java int[] | ||
| </ | </ | ||
documents/120206pyip_cooking/python_imagej_cookbook.txt · Last modified: 2025/10/05 22:53 by kota
                
                