红外小目标检测matlab程序——基于《Infrared Small-Target Detection Using Multiscale Gray Difference Weighted Image》
2016-11-04 10:46
423 查看
阅读了论文《Infrared Small-Target Detection Using Multiscale Gray Difference Weighted Image Entropy》,小菜鸟决定用MATLAB实现一下
![](http://static.blog.csdn.net/xheditor/xheditor_emot/default/wronged.gif)
。
clear;clc;
K=3;
w=2;
c=0.5;
I=imread('3.jpg');
f=rgb2gray(I);
[M N]=size(f);
subplot(2,3,1);imshow(f);
title('原始图像');
%----------------------图像预处理 滤波----------------
K1=filter2(fspecial('average',7),f)/255; %均值滤波
K2=filter2(fspecial('gaussian',3,1.5),f)/255;%高斯滤波
K3=filter2(fspecial('motion',3,0),f)/255;%运动
K4= filter2(fspecial('disk',3),f)/255;%圆形区域均值滤波
K5= medfilt2(f,[7,7]); %中值滤波
subplot(2,3,2);imshow(K1);
title('改进后的图像1');
subplot(2,3,3);imshow(K2);
title('改进后的图像2');
subplot(2,3,4); imshow(K3);
title('改进后的图像3');
subplot(2,3,5);imshow(K4);
title('改进后的图像4');
subplot(2,3,6);imshow(K5);
title('改进后的图像5');
%%%%%%%%选用中值滤波
f=K5;
%----------------------计算图像的NWIE值----------------
D=zeros(1,K);%K为子窗口个数,这里取3,最大窗口尺寸为7*7
num=(M-8)*(N-8);
NWIE=zeros(1,num);
%外围像素不作处理
for i=5:M-4
for j=5:N-4
r=(N-8)*(i-5)+j-5+1;
%计算多尺度灰度差异Dm
for k=1:K
avergray1 = avergray(f,i,j,k);
avergray2 = avergray(f,i,j,K);
Dk=(abs(avergray1-avergray2))^2;
D(k)=Dk;
end
Dm=max(D);
%计算局部熵H
Hist=zeros(1,256);
for p=i-w:i+w %这里取5*5的窗口,w=2
for q=j-w:j+w
Hist(f(p,q)+1)=Hist(f(p,q)+1)+1; %统计局部直方图
end
end
Hist=Hist/sum(Hist);
for k=1:256
if Hist(k)~=0
H=Hist(k)*log(1/Hist(k)); %局部熵
end
end
f(i,j)=Dm*H; %代替中心像素值
NWIE(r)=Dm*H;%存储NWIE的值
end
end
%----------------------计算阈值并分割----------------
%计算阈值
SNR=(max(NWIE)-mean(NWIE))/std(NWIE);
T=c*(max(NWIE)-mean(NWIE))+mean(NWIE);
%分割
figure,imshow(f),title('原图');
for i=1:M
for j=1:N
if f(i,j)>=T
f(i,j)=255;
else
f(i,j)=0;
end
end
end
figure,imshow(f),title('结果图');
%%%%%计算区域平均灰度值的函数
function avergray = avergray(f,x,y,k)
%图像矩阵,中心像素坐标,子窗口序号
num=(2*k+1)^2;
gray=0;
for i=x-k:x+k
for j=y-k:y+k
gray=gray+double(f(i,j));%????????
end
end
avergray =uint8(gray/num);
end
![](http://static.blog.csdn.net/xheditor/xheditor_emot/default/wronged.gif)
。
clear;clc;
K=3;
w=2;
c=0.5;
I=imread('3.jpg');
f=rgb2gray(I);
[M N]=size(f);
subplot(2,3,1);imshow(f);
title('原始图像');
%----------------------图像预处理 滤波----------------
K1=filter2(fspecial('average',7),f)/255; %均值滤波
K2=filter2(fspecial('gaussian',3,1.5),f)/255;%高斯滤波
K3=filter2(fspecial('motion',3,0),f)/255;%运动
K4= filter2(fspecial('disk',3),f)/255;%圆形区域均值滤波
K5= medfilt2(f,[7,7]); %中值滤波
subplot(2,3,2);imshow(K1);
title('改进后的图像1');
subplot(2,3,3);imshow(K2);
title('改进后的图像2');
subplot(2,3,4); imshow(K3);
title('改进后的图像3');
subplot(2,3,5);imshow(K4);
title('改进后的图像4');
subplot(2,3,6);imshow(K5);
title('改进后的图像5');
%%%%%%%%选用中值滤波
f=K5;
%----------------------计算图像的NWIE值----------------
D=zeros(1,K);%K为子窗口个数,这里取3,最大窗口尺寸为7*7
num=(M-8)*(N-8);
NWIE=zeros(1,num);
%外围像素不作处理
for i=5:M-4
for j=5:N-4
r=(N-8)*(i-5)+j-5+1;
%计算多尺度灰度差异Dm
for k=1:K
avergray1 = avergray(f,i,j,k);
avergray2 = avergray(f,i,j,K);
Dk=(abs(avergray1-avergray2))^2;
D(k)=Dk;
end
Dm=max(D);
%计算局部熵H
Hist=zeros(1,256);
for p=i-w:i+w %这里取5*5的窗口,w=2
for q=j-w:j+w
Hist(f(p,q)+1)=Hist(f(p,q)+1)+1; %统计局部直方图
end
end
Hist=Hist/sum(Hist);
for k=1:256
if Hist(k)~=0
H=Hist(k)*log(1/Hist(k)); %局部熵
end
end
f(i,j)=Dm*H; %代替中心像素值
NWIE(r)=Dm*H;%存储NWIE的值
end
end
%----------------------计算阈值并分割----------------
%计算阈值
SNR=(max(NWIE)-mean(NWIE))/std(NWIE);
T=c*(max(NWIE)-mean(NWIE))+mean(NWIE);
%分割
figure,imshow(f),title('原图');
for i=1:M
for j=1:N
if f(i,j)>=T
f(i,j)=255;
else
f(i,j)=0;
end
end
end
figure,imshow(f),title('结果图');
%%%%%计算区域平均灰度值的函数
function avergray = avergray(f,x,y,k)
%图像矩阵,中心像素坐标,子窗口序号
num=(2*k+1)^2;
gray=0;
for i=x-k:x+k
for j=y-k:y+k
gray=gray+double(f(i,j));%????????
end
end
avergray =uint8(gray/num);
end
相关文章推荐
- 算法实现Alg17《Infrared Small-Target Detection Using Multiscale Gray Difference Weighted Image Entropy 》
- 一分钟了解“文章Infrared Small-Target Detection Using Multiscale Gray Difference Weighted Image Entropy”
- Medical image fusion using multi-level local extrema论文matlab程序
- 基于小波包变换和高阶统计量的高斯判别准则的红外小目标的分割程序V2.0-MATLAB版
- 基于detectMultiScale函数多尺度人脸检测确定目标尺寸
- 基于小波包变换和高阶统计量的高斯判别准则的红外小目标的分割程序V1.0-MATLAB版
- detectMultiScale 基于级联分类器的目标检测objdect
- 人脸检测对齐--Joint Face Detection and Alignment using Multi-task Cascaded Convolutional Networks
- 基于视频的移动目标检测 Moving Object Detection
- [深度学习论文笔记][Depth Estimation] Depth Map Prediction from a Single Image using a Multi-Scale Deep Netw
- Improving Multiview Face Detection with Multi-Task Deep Convolutional Neural Networks 基于深度学习的人脸检测算法
- 目标检测中的尺度--An Analysis of Scale Invariance in Object Detection – SNIP
- 一分钟了解“文章Small Infrared Target Detection Based on Weighted Local Difference Measure”
- Depth Map Prediction from a Single Image using a Multi-Scale Deep Network
- 基于深度学习的目标检测(object detection)—— rcnn、fast-rcnn、faster-rcnn
- opencv程序十九:基于帧间差分法的区域目标入侵检测
- 快速多尺度人脸检测--Multi-Scale Fully Convolutional Network for Fast Face Detection
- 基于RNN的在线多目标跟踪——OnLine Multi-Target Tracking Using Recurrent Neural Networks
- [翻译] NSImage+HHTint - Tints grayscale images using CoreImage
- 【深度学习:目标检测】RCNN学习笔记(9):OverFeat:Integrated Recognition, Localization and Detection using Convolution