一分钟了解"用matlab计算信杂比SCR 以及 背景区域的标准差"

来源:互联网 发布:淘宝人气值是什么 编辑:程序博客网 时间:2024/05/16 05:43
%求SCR和方差的方法
clear,clc,close all
imgName=input('请输入bmp文件名,要有单引号,要有后缀:');
img=imread(imgName);
figure,imshow(img,[])
leftupPointRow=input('请输入目标的左上角的行数(第二坐标):');
leftupPointCol=input('请输入目标的左上角的列数(第一坐标):');
rightdownPointRow=input('请输入目标的右下角的行数(第二坐标):');
rightdownPointCol=input('请输入目标的右下角的列数(第一坐标):');
backgroundAreaWidth=10;
targetVector=img(leftupPointRow:rightdownPointRow,leftupPointCol:rightdownPointCol)
targetSize=size(targetVector);
targetVector=double( targetVector(:) );

backgroundVector1=img(leftupPointRow-10:rightdownPointRow+10,leftupPointCol-backgroundAreaWidth:leftupPointCol-1)
backgroundVector2=img(leftupPointRow-10:rightdownPointRow+10,rightdownPointCol+1:rightdownPointCol+10)
backgroundVector3=img(leftupPointRow-10:leftupPointRow-1,leftupPointCol:rightdownPointCol)
backgroundVector4=img(rightdownPointRow+1:rightdownPointRow+10,leftupPointCol:rightdownPointCol)
backgroundVector=[backgroundVector1(:);backgroundVector2(:);backgroundVector3(:);backgroundVector4(:)];
backgroundVector=double(backgroundVector);
scr=(mean(targetVector)-mean(backgroundVector))/std(backgroundVector);
fprintf(['目标的尺寸是',num2str(targetSize(1)),'x',num2str(targetSize(2)),'\n']);
fprintf(['SCR=',num2str(scr),'\n']);
fprintf(['std(background)=',num2str(std(backgroundVector)),'\n']);


阅读全文
0 0