Chein-I Chang老师PPI算法中的未定义函数
**代码来源:**Chein-I Chang老师 HYPERSPECTRAL DATA
PROCESSING:Algorithm Design and Analysis 一书。
**站内下载地址:**https://download.csdn.net/download/cgs425449830/10636420?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522160767189619725271043769%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=160767189619725271043769&biz_id=1&utm_medium=distribute.pc_search_result.none-task-download-2allfirst_rank_v2~rank_v29-1-10636420.nonecase&utm_term=HYPERSPECTRAL%20DATA%20PROCESSING%EF%BC%9AAlgorithm%20Design%20and%20Analysis&spm=1018.2118.3001.4449
本文解决问题:直接粘贴书中代码运行时会出现translate_index函数没有定义。
联系代码的上下文及PPI的原理,这个算法的定义是将一元位置的矩阵还原至原来的二元图像矩阵位置。因此补充该函数如下
function[eeindex]= translate_index(re,rows,columns)
%Complement Dr Ccheng's PPI algorithm
ee = zeros(1,1);
D = zeros(rows*columns,1);
for i = 1:length(re)
D(re(i)) = 1;
end
E = reshape(D,rows,columns);
[x,y]= find(E>0);
eeindex = [x,y];