【图像提取】基于matlab PCA-CSIFT feature图像特征提取【含Matlab源码 1174期】
一、获取代码方式
获取代码方式1:
完整代码已上传我的资源:【图像提取】基于matlab PCA-CSIFT feature图像特征提取【含Matlab源码 1174期】
获取代码方式2:
通过订阅紫极神光博客付费专栏,凭支付凭证,私信博主,可获得此代码。
备注:
订阅紫极神光博客付费专栏,可免费获得1份代码(有效期为订阅日起,三天内有效);
二、简介
三、部分源代码
%%initial image and create input H image.
clear;
clc
img=imread('test.png');
row=256;
colum=256;
img=imresize(img,[row,colum]);
transfer_matrix=[0.06,0.63,0.27;0.3,0.04,-0.35;0.34,-0.6,0.17];
R=img(:,:,1);
G=img(:,:,2);
B=img(:,:,3);
e=transfer_matrix(1,1)*R+transfer_matrix(1,2)*G+transfer_matrix(1,3)*B;
e1=transfer_matrix(2,1)*R+transfer_matrix(2,2)*G+transfer_matrix(2,3)*B;
e2=transfer_matrix(3,1)*R+transfer_matrix(3,2)*G+transfer_matrix(3,3)*B;
H=(double(e1)./double(e2));
origin=img;
img=H;
[m,n]=size(img);
%% Scale-Space Extrema Detection
% original sigma and the number of actave can be modified.
sigma=1.6;
octave=3;%6*sigma*k^(octave*level)<=min(m,n)/(2^(octave-2))
level=5;
k=2^(1/level);
D=cell(1,octave);
for i=1:octave
D(i)=mat2cell(zeros(row*2^(2-i)+2,colum*2^(2-i)+2,level),row*2^(2-i)+2,colum*2^(2-i)+2,level);
end
% first image in first octave is created by interpolating the original one.
temp_img=img(1:1/2:m,1:1/2:n);
temp_img=padarray(temp_img,[1,1],'pre');
temp_img=padarray(temp_img,[1,1],'replicate');
%create the DoG pyramid.
for i=1:octavetemp_D=D{i};sigma=sigma*sqrt(2)^(i-1);for j=1:levelp=(level)*(i-1);figure(1);subplot(octave,level,p+j);f=fspecial('gaussian',[1,floor(6*sigma*k^(p+j-1))],sigma*k^(p+j-1));L1=temp_img;if(i==1&&j==1)L2=conv2(temp_img,f,'same');L2=conv2(L2,f','same');temp_D(:,:,j)=L2-L1;imshow(uint8(255 * mat2gray(temp_D(:,:,j))));L1=L2;elseL2=conv2(temp_img,f,'same');L2=conv2(L2,f','same');temp_D(:,:,j)=L2-L1;L1=L2;if(j==level)temp_img=L1(2:end-1,2:end-1);endimshow(uint8(255 * mat2gray(temp_D(:,:,j))));endendD{i}=temp_D;temp_img=temp_img(1:2:end,1:2:end);temp_img=padarray(temp_img,[1,1],'replicate');
end
%% Keypoint Localistaion
% search each pixel in the DoG map to find the extreme point
interval=level-1;
extrema=[];
for i=1:octave[m,n,~]=size(D{i});m=m-2;n=n-2;volume=m*n/(4^(i-1));for k=2:interval for j=1:volume% starter=D(ceil(i/m)+1,mod(i-1,n)+1+1,j);sub=D{i}(ceil(j/m):ceil(j/m)+2,mod(j-1,n)+1:mod(j-1,n)+3,k-1:k+1);large=max(max(max(sub)));little=min(min(min(sub)));if(large==D{i}(ceil(j/m)+1,mod(j-1,n)+1+1,k))temp=[i,k,j,1];extrema=[extrema,temp];endif(little==D{i}(ceil(j/m)+1,mod(j-1,n)+1+1,k))temp=[i,k,j,-1];extrema=[extrema,temp];endendend
end
%% accurate keypoint localization
%eliminate the point with low contrast or poorly localised on an edge
% x:|,y:-- x is for vertial and y is for horizontal
% value comes from the paper.
threhold=0.03;
r=10;
extr_volume=length(extrema)/4;
[m,n]=size(img);
for i=1:extr_volumex=floor((extrema(4*(i-1)+3)-1)/(m/(2^(extrema(4*(i-1)+1)-2))))+1;y=mod((extrema(4*(i-1)+3)-1),n/(2^(extrema(4*(i-1)+1)-2)))+1;rx=x+1;ry=y+1;rz=extrema(4*(i-1)+2);z=D{extrema(4*(i-1)+1)}(rx,ry,rz);if(abs(z)<threhold)extrema(4*(i-1)+4)=0;else Dxx=D{extrema(4*(i-1)+1)}(rx-1,ry,rz)+D{extrema(4*(i-1)+1)}(rx+1,ry,rz)-2*D{extrema(4*(i-1)+1)}(rx,ry,rz);Dyy=D{extrema(4*(i-1)+1)}(rx,ry-1,rz)+D{extrema(4*(i-1)+1)}(rx,ry+1,rz)-2*D{extrema(4*(i-1)+1)}(rx,ry,rz);Dxy=D{extrema(4*(i-1)+1)}(rx-1,ry-1,rz)+D{extrema(4*(i-1)+1)}(rx+1,ry+1,rz)-D{extrema(4*(i-1)+1)}(rx-1,ry+1,rz)-D{extrema(4*(i-1)+1)}(rx+1,ry-1,rz);deter=Dxx*Dyy-Dxy*Dxy;R=(Dxx+Dyy)/deter;R_threshold=(r+1)^2/r;if(deter<0||R>R_threshold)extrema(4*(i-1)+4)=0;endend
end
flag=[];
for i=1:1:extr_volumeif(extrema(4*(i-1)+4)==0)flag=[flag,(4*(i-1)+1:4*i)];end
end
extrema(flag)=[];
extr_volume=length(extrema)/4;
% eliminate the points on the image edge.
flag=[];
for i=1:extr_volumex=floor((extrema(4*(i-1)+3)-1)/(m/(2^(extrema(4*(i-1)+1)-2))))+1;y=mod((extrema(4*(i-1)+3)-1),n/(2^(extrema(4*(i-1)+1)-2)))+1;if(x==1||x==m/(2^(extrema(4*(i-1)+1)-2))||y==1||y==n/(2^(extrema(4*(i-1)+1)-2)))flag=[flag,(4*(i-1)+1:4*i)];end
end
extrema(flag)=[];
extr_volume=length(extrema)/4;
figure(2)
imshow(origin);
for i=1:extr_volumex=floor((extrema(4*(i-1)+3)-1)/(m/(2^(extrema(4*(i-1)+1)-2))))+1;y=mod((extrema(4*(i-1)+3)-1),n/(2^(extrema(4*(i-1)+1)-2)))+1;rx=x/2^(octave-1-extrema(4*(i-1)+1));ry=y/2^(octave-1-extrema(4*(i-1)+1));text(ry,rx,'*','Color','green');
end
hold on
%% pre-compute eigenspace of each extre point
flag=[];
A=[];
for i=1:extr_volumex=floor((extrema(4*(i-1)+3)-1)/(m/(2^(extrema(4*(i-1)+1)-2))))+1;y=mod((extrema(4*(i-1)+3)-1),n/(2^(extrema(4*(i-1)+1)-2)))+1;rx=x+1;ry=y+1;rz=extrema(4*(i-1)+2);width=41; if(x>(width/2)&&y>(width/2)&&x<(m/2^(extrema(4*(i-1)+1)-2)-width/2-2)&&y<(n/2^(extrema(4*(i-1)+1)-2)-width/2-2))patch=D{extrema(4*(i-1)+1)}(rx-(width-1)/2:rx+(width-1)/2,ry-(width-1)/2:ry+(width-1)/2,rz); [Dx,Dy]=gradient(patch);G=zeros(1,2*width*width);j=1;for p=1:widthfor q=1:widthG(j)=Dx(p,q);G(j+1)=Dy(p,q);j=j+2;endendA=[A;G];elseflag=[flag,(4*(i-1)+1:4*i)];end
end
extrema(flag)=[];
extr_volume=length(extrema)/4;
[p,q]=size(A);
M=A-repmat(mean(A,1),p,1);
conv=M'*M;
[V,~]=eig(conv);
N=20;
project=V(:,(end-N+1):end)';
%% Orientation Assignment(Main orientations assignment)
kpori=[];
flag=[];
for i=1:extr_volume%search in the certain scalesigma=1.6*sqrt(2)^(extrema(4*(i-1)+1));width=2*round(3*1.5*sigma);count=1;x=floor((extrema(4*(i-1)+3)-1)/(m/(2^(extrema(4*(i-1)+1)-2))))+1;y=mod((extrema(4*(i-1)+3)-1),n/(2^(extrema(4*(i-1)+1)-2)))+1;%make sure the point in the searchable areaif(x>(width/2)&&y>(width/2)&&x<(m/2^(extrema(4*(i-1)+1)-2)-width/2-2)&&y<(n/2^(extrema(4*(i-1)+1)-2)-width/2-2))rx=x+1;ry=y+1;rz=extrema(4*(i-1)+2);reg_volume=width*width;%3? thereom% make weight matrixweight=zeros(width,width);for p=1:widthfor q=1:widthweight(p,q)=exp(-((p-width/2)^2+(q-width/2)^2)/(1.5*sigma));endend%calculate region pixels' magnitude and region orientationreg_mag=zeros(1,count);reg_theta=zeros(1,count);for l=(rx-width/2):(rx+width/2-1)for k=(ry-width/2):(ry+width/2-1)reg_mag(count)=sqrt((D{extrema(4*(i-1)+1)}(l+1,k,rz)-D{extrema(4*(i-1)+1)}(l-1,k,rz))^2+(D{extrema(4*(i-1)+1)}(l,k+1,rz)-D{extrema(4*(i-1)+1)}(l,k-1,rz))^2);reg_theta(count)=atan2((D{extrema(4*(i-1)+1)}(l,k+1,rz)-D{extrema(4*(i-1)+1)}(l,k-1,rz)),(D{extrema(4*(i-1)+1)}(l+1,k,rz)-D{extrema(4*(i-1)+1)}(l-1,k,rz)))*(180/pi);count=count+1;endend
四、运行结果
五、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1] 蔡利梅.MATLAB图像处理——理论、算法与实例分析[M].清华大学出版社,2020.
[2]杨丹,赵海滨,龙哲.MATLAB图像处理实例详解[M].清华大学出版社,2013.
[3]周品.MATLAB图像处理与图形用户界面设计[M].清华大学出版社,2013.
[4]刘成龙.精通MATLAB图像处理[M].清华大学出版社,2015.
【图像提取】基于matlab PCA-CSIFT feature图像特征提取【含Matlab源码 1174期】相关推荐
- 【Matlab图像融合】小波变换遥感图像融合【含GUI源码 744期】
一.代码运行视频(哔哩哔哩) [Matlab图像融合]小波变换遥感图像融合[含GUI源码 744期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1] 包子阳,余 ...
- 【Matlab图像加密】正交拉丁方置乱算法图像加解密【含GUI源码 182期】
一.代码运行视频(哔哩哔哩) [Matlab图像加密]正交拉丁方置乱算法图像加解密[含GUI源码 182期] 二.matlab版本及参考文献 一.代码运行视频(哔哩哔哩) [Matlab图像处理]自动 ...
- 【Matlab语音隐写】DCT+DWT音频数字水印嵌入提取【含GUI源码 836期】
一.代码运行视频(哔哩哔哩) [Matlab语音隐写]DCT+DWT音频数字水印嵌入提取[含GUI源码 836期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1 ...
- 【Matlab车牌识别】停车计费系统【含GUI源码 735期】
一.代码运行视频(哔哩哔哩) [Matlab车牌识别]停车计费系统[含GUI源码 735期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1] 蔡利梅.MATLA ...
- 【Matlab人脸识别】BP神经网络人脸识别(含识别率)【含GUI源码 891期】
一.代码运行视频(哔哩哔哩) [Matlab人脸识别]BP神经网络人脸识别(含识别率)[含GUI源码 891期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1] ...
- 【Matlab人脸识别】形态学教室人数统计(带面板)【含GUI源码 1703期】
一.代码运行视频(哔哩哔哩) [Matlab人脸识别]形态学教室人数统计(带面板)[含GUI源码 1703期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1]孟 ...
- 【Matlab人脸识别】人脸实时检测与跟踪【含GUI源码 673期】
一.代码运行视频(哔哩哔哩) [Matlab人脸识别]人脸实时检测与跟踪[含GUI源码 673期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1]孟逸凡,柳益君 ...
- 【Matlab生物电信号】生物电信号仿真【含GUI源码 684期】
一.代码运行视频(哔哩哔哩) [Matlab生物电信号]生物电信号仿真[含GUI源码 684期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1]董兵,超于毅,李 ...
- 【Matlab语音分析】语音信号分析【含GUI源码 1718期】
一.代码运行视频(哔哩哔哩) [Matlab语音分析]语音信号分析[含GUI源码 1718期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1]韩纪庆,张磊,郑铁 ...
- 【Matlab验证码识别】遗传算法和最大熵优化+大津法(OTSU)+自定义阈值数字验证码识别【含GUI源码 1694期】
一.代码运行视频(哔哩哔哩) [Matlab验证码识别]遗传算法和最大熵优化+大津法(OTSU)+自定义阈值数字验证码识别[含GUI源码 1694期] 二.matlab版本及参考文献 1 matlab ...
最新文章
- php fprintf,PHP fprintf() 函数 | 菜鸟教程
- Linux中命令链接操作符的十个最佳实例
- 关于 Notepad++ 崩溃之后正在编辑文件内容被清空的致命问题的补救措施
- 这次是在没有外网yum仓库的情况下搭建内网yum仓库和无人值守pxe装机
- 机房收费系统之抽象工厂篇
- power bi 中计算_Power BI中的期间比较
- 模拟jQuery--获取事件的封装
- mysql ak uk_mysql表的查询
- 小度c1语言控制电视,小度在家1c怎么连接电视机
- 程序员如何学习一门新技术?
- 统计|如何理解两个总体均值之差的区间估计的计算
- 太牛了!某大佬程序猿北漂16年,从睡天桥到身价数千万,衣锦还乡重庆住豪宅!...
- matplotlib显示宋体和Times New Roman
- 百度地图开发Sug检索Demo
- 涂涂乐的详细实现之四--unity3d调用EmguCV实现图片识别
- ui设计师色彩运用_网页设计师的20多种色彩工具
- 注册石墨文档无法连接服务器,石墨文档没有访问权限是怎么回事?权限解决方法看这里!...
- Keystone的安装及其配置
- 双曲嵌入论文与代码实现——1. 数据集介绍
- 手机内存卡转化linux,怎样把手机内存移至sd内存卡
热门文章
- 3. file、inode结构体及chardevs数组等相关知识解析
- xxx.app已损坏,打不开.你应该将它移到废纸篓-已解决
- 关于实现servlet中心控制的Front Controller Pattern
- codesmith执行时提示“调用的目标发生了异常”的处理过程经验。
- 笑话一则(小狗的故事)
- Item 10.const成员函数 (Meaning of a Const Member Function)
- 传智播客Java 二维数组
- Python 操作快捷键
- 史上最全的人工智能知识体系大全图谱 中国人工智能发展现状与未来
- getchar() 和getch()