使用ImageJ软件计算信噪比(SNR)的小工具

本人是做医学影像设备的,最近在做一款X光片读取的机器。生产出厂检测时,需要检查一下读取的X光片图像的信噪比(SNR)。

1. 先说一下SNR检测的方法:

    1)先拍一张X光片,机器读取光片,图像存在固定的目录

    2)用ImageJ软件打开图像,选取10个不同的区域,分别求出10组不同区域的平均灰度值MEAN_AVERAGE和平均方根差STD_AVERAGE.

    3)SNR = MEAN_AVERAGE/STD_AVERAGE

2. 使用宏实现1中的操作,修改StartupMacros.txt文件如下:

macro "SNR TEST" {
var area;
var mean;
var max;
var std;

var sum_area = 0;
var sum_mean = 0;
var sum_max = 0;
var sum_std = 0;
var SNR;

open("C:\\s2terminal\\image.dcm"); //打开图像文件
run("Grid ", "grid=Lines area=9 color=Cyan");


makeRectangle(152, 250, 98, 102);//选取第一个区域
getStatistics(area, mean, min, max, std, histogram);
sum_area = sum_area + area;
sum_mean = sum_mean + mean;
sum_min = sum_min + min;
sum_max = sum_max + max;
sum_std = sum_std +std;

makeRectangle(352, 250, 98, 98);//选取第2个区域
getStatistics(area, mean, min, max, std, histogram);
sum_area = sum_area + area;
sum_mean = sum_mean + mean;
sum_min = sum_min + min;
sum_max = sum_max + max;
sum_std = sum_std + std;

makeRectangle(552, 352, 100, 94);////选取第3个区域
getStatistics(area, mean, min, max, std, histogram);
sum_area = sum_area + area;
sum_mean = sum_mean + mean;
sum_min = sum_min + min;
sum_max = sum_max + max;
sum_std = sum_std + std;

makeRectangle(352, 550, 98, 100);//选取第4个区域
getStatistics(area, mean, min, max, std, histogram);
sum_area = sum_area + area;
sum_mean = sum_mean + mean;
sum_min = sum_min + min;
sum_max = sum_max + max;
sum_std = sum_std + std;

makeRectangle(652, 550, 100, 104);//选取第5个区域
getStatistics(area, mean, min, max, std, histogram);
sum_area = sum_area + area;
sum_mean = sum_mean + mean;
sum_min = sum_min + min;
sum_max = sum_max + max;
sum_std = sum_std + std;

makeRectangle(352, 1052, 98, 94);////选取第6个区域
getStatistics(area, mean, min, max, std, histogram);
sum_area = sum_area + area;
sum_mean = sum_mean + mean;
sum_min = sum_min + min;
sum_max = sum_max + max;
sum_std = sum_std + std;

makeRectangle(150, 852, 100, 98);//选取第7个区域
getStatistics(area, mean, min, max, std, histogram);
sum_area = sum_area + area;
sum_mean = sum_mean + mean;
sum_min = sum_min + min;
sum_max = sum_max + max;
sum_std = sum_std + std;

makeRectangle(352, 852, 98, 100);////选取第8个区域
getStatistics(area, mean, min, max, std, histogram);
sum_area = sum_area + area;
sum_mean = sum_mean + mean;
sum_min = sum_min + min;
sum_max = sum_max + max;
sum_std = sum_std + std;

makeRectangle(550, 852, 102, 100);//选取第9个区域
getStatistics(area, mean, min, max, std, histogram);
sum_area = sum_area + area;
sum_mean = sum_mean + mean;
sum_min = sum_min + min;
sum_max = sum_max + max;
sum_std = sum_std + std;

makeRectangle(750, 950, 100, 98);//选取第10个区域
getStatistics(area, mean, min, max, std, histogram);
sum_area = sum_area + area;
sum_mean = sum_mean + mean;
sum_min = sum_min + min;
sum_max = sum_max + max;
sum_std = sum_std + std;

sum_mean = sum_mean/10;//mean_average
sum_std = sum_std/10;
SNR = (16383 - sum_mean)/sum_std;//std_average
sum_mean = 16383 - sum_mean;
print("16383 - sum_mean = "+sum_mean);
print("average std = "+sum_std);
print("SNR = "+SNR);

close();


  }
  
  macro "About ImageJ Action Tool - C059T3e16S" {
doCommand("SNR TEST");
}


3. 重新启动软件,界面如下:


使用ImageJ软件计算信噪比(SNR)的小工具_第1张图片


使用ImageJ软件计算信噪比(SNR)的小工具_第2张图片


用户可以直接点击S键或者SNR TEST菜单,直接计算SNR.

使用ImageJ软件计算信噪比(SNR)的小工具_第3张图片




你可能感兴趣的:(图像处理)