// The current output is saved to the desktop, with the file named "result.csv". You can change to another output file path
var outputFile = getDirectory("home") + "Desktop/result.csv";
var header = "ROI,Point\n"; // Header of the CSV file
var data = ""; // String for collecting data
// Set parameters for Find Maxima
noiseTolerance = 10; // Adjust noise tolerance as needed
outputType = "Point Selection"; // Choose output type: "List" or "Point Selection"
excludeEdgeMaxima = true; // Whether to exclude edge maxima
lightBackground = false; // Set true/false depending on image background; false for dark background
minIntensity = 5; // 调整这个值
// Get the number of ROIs from ROI Manager
command = "noise=" + noiseTolerance + " output=[Point Selection]";
// Iterate through each ROI
for (i=0; i roiManager("select", i); // Select current ROI
// 最小修改:先把ROI转换成8-bit灰度图像
run("Duplicate...", "title=temp_roi");
run("Find Maxima...", command);
getSelectionCoordinates(xPoints, yPoints);
for (p=0; p x = xPoints[p];
intensity = getPixel(x, y); // 现在返回单个强度值
if (intensity >= minIntensity) {
nMaxima = validCount; // 使用筛选后的数量
data = data + i + "," + nMaxima + "\n";
File.saveString(data, outputFile);