✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。
🍎个人主页:Matlab科研工作室
🍊个人信条:格物致知。
更多Matlab仿真内容点击👇
智能优化算法 神经网络预测 雷达通信 无线传感器
信号处理 图像处理 路径规划 元胞自动机 无人机 电力系统
⛄ 内容介绍
合成孔径雷达(Synthetic Aperture Radar,SAR)是一种高分辨率相干成像雷达.与红外和可见光遥感技术相比,SAR具有全天时,全天候工作的优点,因此广泛应用于军事和国民经济邻域.SAR图像分割是SAR图像处理的重要环节,是影响SAR自动解译性能的关键技术之一. 模糊c均值(FCM)聚类算法是模糊聚类分析中的经典算法,比较适合处理图像中的不确定性问题,已经广泛应用于图像分割中.
⛄ 部分代码
clear;
clc;
close all;
addpath('./utils');
addpath('./liblinear');
% im1 = imread('./pic/san_1.bmp');
% im2 = imread('./pic/san_2.bmp');
% im_gt = imread('./pic/san_gt.bmp');
% im1 = imread('./pic/bern_1.bmp');
% im2 = imread('./pic/bern_2.bmp');
% im_gt = imread('./pic/bern_gt.bmp');
% fprintf(' ... ... read image file finished !!! !!!\n\n');
% im1 = imread('./pic/san_1.bmp');
% im2 = imread('./pic/san_2.bmp');
% im_gt = imread('./pic/san_gt.bmp');
% im1 = imread('E:\图像处理文件\变化检测3\daima文献\GaoFeng\SAR_Change_Detection_CWNN-master\pic\Sulzberger1_1.bmp');
% im2 = imread('E:\图像处理文件\变化检测3\daima文献\GaoFeng\SAR_Change_Detection_CWNN-master\pic\Sulzberger1_2.bmp');
% im_gt = imread('E:\图像处理文件\变化检测3\daima文献\GaoFeng\SAR_Change_Detection_CWNN-master\pic\Sulzberger1_gt.bmp');
% im1 = imread('.\Ottawa-SAR\im1.bmp');
% im2 = imread('.\Ottawa-SAR\im2.bmp');
%
% im_gt = imread('.\Ottawa-SAR\im3.bmp');
% im1 = imread('.\Yellow River I-SAR\im1.bmp');
% im2 = imread('.\Yellow River I-SAR\im2.bmp');
% im_gt = imread('.\Yellow River I-SAR\rf.bmp');
im1 = imread('data\im1.bmp');
im2 = imread('data\im2.bmp');
%291*306
im_gt = imread('data\rf.bmp');
%%去噪
% im1=YZmedian(im1,20,9);%阈值分解中值滤波 im1=YZmedian(im1,1.6,9)
% figure,imshow(im1);
% title('时相1滤波后');
% im2=YZmedian(im2,20,9);%阈值分解中值滤波
% figure,imshow(im2);
% title('时相2滤波后');
im1 = double(im1(:,:,1));
im2 = double(im2(:,:,1));
im_gt = double(im_gt(:,:,1));
% im1 = double(im1);
% im2 = double(im2);
% im_gt = double(im_gt(:,:,1));
% % 求差分图像,得到差分图像后进行了滤波预处理
% fprintf('... ... compute the difference image ... ...\n');
im_di = di_gen(im1, im2);%对数比值法
% im_di = getPCAFusion(im1,im2);
% figure,imshow(im_di);
%邻域比值法
% k_n=3;
% im_di = nr(im1, im2, k_n);
% im_di = max(im_di(:))-im_di;
% im_di = nr_enhance( im_di );
% % figure,imshow(im_di);
% im_di=load('DI_fusion.mat');
% im_di=struct2array(load('DI_fusion.mat'));
% setting of variables
% 这些参数来自 GaborTLC 的一些默认参数
PatSize =9;
% HW =18;% 10 15
HW = 21;
GaborH = HW;
GaborW = HW;
sigma =1.9*pi;%5.2 3.2 3.1
Kmax =1.9*pi;%5.2-1.8
f = sqrt(2);
flag = 1;
scale = 5;
orientation = 8;
% sigma = 2.8*pi;
% Kmax = 2.0*pi;
% f = sqrt(2);
% flag = 1;
% scale = 5;
% orientation = 8;
V = 0:1:(scale-1);
U = 0:1:(orientation-1);
% [Ylen,Xlen] = size(im_di); %%%%%%
[Ylen,Xlen] = size(im_di);
% the total number of pixels for the difference image
pixel_sum = Ylen*Xlen;
% the total number of self-similar Gabor filters
subgraph_sum = scale*orientation;
% Initialization
GaImout_MAGNITUDE = cell(scale,orientation); % magnitude
% Step 2): Feature extraction==============================================
% Gabor wavelet transform
for s = 1:scale,
for n = 1:orientation,
GaImout_MAGNITUDE{s,n} = zeros(Ylen,Xlen);
[Gr,Gi] = GaborKernelWave(GaborH, GaborW, U(n), V(s), Kmax, f, sigma, orientation, flag);
% Gr: The real part of the Gabor kernels
% Gi: The imaginary part of the Gabor kernels
Regabout = conv2(im_di,double(Gr),'same');%im_di与double(Gr) 卷积, same:返回与 A 大小相同的卷积的中心部分
Imgabout = conv2(im_di,double(Gi),'same');
% Regabout = conv2(im_di,double(Gr),'same'); %im_di与double(Gr) 卷积, same:返回与 A 大小相同的卷积的中心部分
% Imgabout = conv2(im_di,double(Gi),'same');
% Magnitude 大小
GaImout_MAGNITUDE{s,n} = sqrt(Imgabout.*Imgabout + Regabout.*Regabout);
end;
end;
clear GaborH GaborW sigma;
clear Gi Gr HW Kmax;
clear Imgabout Regabout;
clear U V f flag;
% acquire the feature vector of each pixel for the difference image
% 1): all amplitudes at different scales and orientations
% 获取差分图像每个像素的特征向量% 1) : 不同尺度和方向的所有幅度
pixel_vector_1 = zeros(pixel_sum,subgraph_sum);
k = 1;
for s = 1:scale
for n = 1:orientation
temp_gaimout_1 = zeros(Ylen,Xlen);
temp_gaimout_1 = GaImout_MAGNITUDE{s,n};
pixel_vector_1(:,k) = reshape(temp_gaimout_1',pixel_sum,1);
k = k + 1;
end
end
clear k n s GaImout_MAGNITUDE subgraph_sum;
% 2): maximum amplitudes for all orientations at different scales
% 不同尺度上所有方向的最大振幅
pixel_vectorr_2 = zeros(pixel_sum,scale);
for s = 1:scale
temp_gaimout_2 = zeros(pixel_sum,orientation);
temp_gaimout_2 = pixel_vector_1(:,(s-1)*orientation+1:s*orientation);
pixel_vector_2(:,s) = max(temp_gaimout_2,[],2);
end
% % Gabor1=GaborM(im1);
% % Gabor2=GaborM(im2);
clear scale temp_gaimout_1 temp_gaimout_2 pixel_vector_1;
clear s pixel_sum orientation;
% 求差分图像,得到差分图像后进行了滤波预处理
fprintf('... ... compute the difference image ... ...\n');
% pixel_vector_2=GaborM(im_di1);
% Step 3): Hierarchical clustering==========================
fprintf('... ... hclustering begin ... ...\n');
im_lab = HClustering(pixel_vector_2, im_di);
figure,imshow(im_lab);
⛄ 运行结果
⛄ 参考文献
[1]武斌. 模糊聚类在遥感图像分割中的应用研究[D]. 安徽农业大学.
[1]汪柯陆. 基于模糊c均值聚类的SAR图像分割算法研究. Diss. 西安电子科技大学.
⛄ Matlab代码关注
❤️部分理论引用网络文献,若有侵权联系博主删除
❤️ 关注我领取海量matlab电子书和数学建模资料