您的位置:首页 > 编程语言 > MATLAB

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

2017-08-11 22:05 573 查看
%求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']);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: