一个新的斐济插件,用于可视化年内密度波动和分析沿木材横截面的年内理论体积流量波动大家好,我尝试使用这个新的斐济插件来分析我的管胞。图像处理的前导步骤(定位、阈值等)已完成。插件激活后,java控制台中会出现一条错误消息
安慰:
安装 java.nio.charset.UnsupportedCharsetException 失败:cp0。[错误] 空
其次是
[错误] null Traceback(最近一次调用最后一次):文件“IADF-IAVFF_1.0.py”,第 51 行,在 NameError:名称'ResultsTable' 未定义
我加入了python脚本非常感谢您的帮助
import sys
import math
from ij import IJ
from ij.gui import GenericDialog
#Dialog for chosing the analysing mode
def getMode():
gd = GenericDialog("Intra annual analyses")
gd.addMessage("Please choose the analysing mode (picture requirements):\n \n[1] IADF-analysis (binary picture: white cell lumen, black cell walls)\n \n[2] IAVFF-analysis (binary picture: white cell walls, black cell lumen)")
types = ["IADF", "IAVFF"]
gd.addChoice(" analysing mode:", types, types[0])
gd.showDialog()
if gd.wasCanceled():
sys.exit();
IA = gd.getNextChoice()
return IA
#Dialog for entering Hagen-Poiseuille equation parameter
def getParameter():
gd = GenericDialog("Hagen-Poiseuille equation parameter")
gd.addNumericField("dynamic fluid viscosity eta [mPa*s]", 1, 0)
gd.addNumericField("length of pipe L [m]", 1, 0)
gd.addNumericField("pressure difference delta p [MPa]", 1, 0)
gd.showDialog()
if gd.wasCanceled():
sys.exit();
nu = gd.getNextNumber()
L = gd.getNextNumber()
p = gd.getNextNumber()
return nu, L, p
#Obtain Image, Image Processor, height and width
imp = IJ.getImage()
ip = imp.getProcessor().convertToFloat()
x = imp.getWidth()
y = imp.getHeight()
j = 1
i = 1
row = 0
grey = 1.0
sapf_list = []
sapf_pix_list = []
#Chosing analysing mode
mode = getMode()
IA = mode
# IADF-analysis
IJ.run("Set Measurements...", "area centroid perimeter shape feret's area_fraction redirect=None decimal=0")
if IA == "IADF":
table = ResultsTable()
for j in range(x):
su = 0
sup = 0
for i in range(y):
if ip.getPixelValue(j,i) > 0:
su = su + 1
else:
su = su + 0
sup = round(float(su) / y * 100, 2)
table.incrementCounter()
table.addValue("sum of black pixel", su)
table.addValue("percent of black pixel", sup)
table.show("Results")
# IAVFF-analysis
else:
parameter = getParameter()
nu, L, p = parameter
IJ.run("Set Measurements...", "area centroid perimeter shape feret's area_fraction redirect=None decimal=3")
IJ.run("Set Scale...")
imp32 = imp.duplicate()
IJ.run("Analyze Particles...")
rt = ResultsTable.getResultsTable()
IJ.run(imp32, "32-bit", "")
for roi in RoiManager.getInstance().getRoisAsArray():
ip = imp.getProcessor()
a = rt.getValue("Feret", row)
b = rt.getValue("MinFeret", row)
sapf = (math.pi/4) * (1/(nu*L)) * math.pow(a/1000000, 3) * math.pow(b/1000000, 3) / (math.pow(a/1000000, 2) + math.pow(a/1000000, 2))*(p/1000000000)
sapf_list.append(sapf)
rt.setValue("ROI no.", row, row + 1)
rt.setValue("Q", row, sapf)
ip.setRoi(roi)
stats = ImageStatistics.getStatistics(ip, Measurements.AREA, None)
rt.setValue("Pixel count", row, stats.pixelCount)
rt.setValue("Q per Pixel", row, sapf/stats.pixelCount)
sapf_pix_list.append(sapf/stats.pixelCount)
row = row + 1
ip = imp32.getProcessor()
ip.setRoi(roi)
stats = ip.getStatistics()
ip.setValue(grey)
ip.fill(roi)
ip.resetRoi()
grey = grey + 1.0
imp32.show()
rt.show("Results")
table = ResultsTable()
sapf_pix_row_list = []
for j in range(x):
IJ.showProgress(j, x)
sum_sapf_pix = 0
for i in range(y):
if ip.getPixelValue(j, i) != 0.0:
pos = int(ip.getPixelValue(j, i))-1
sum_sapf_pix = sum_sapf_pix + sapf_pix_list[pos]
table.incrementCounter()
table.addValue("Q pixel-row sum", sum_sapf_pix)
IJ.showProgress(1)
table.show("IAVFF-Results")