Bad Pixel Replacement

조회 수: 11 (최근 30일)
James
James 2011년 6월 2일
[EDIT: 20110602 14:20 CDT - reformat - WDR]
I am trying to replace bad pixels in an hyperspectral image. In the code so far i have read the bad pixel file. I then created a matrix in [j,k] or sample and band space of 1's where pixels are bad and 0's where good. Created a linear index of of all the bad pixels (1's). Then I assigned j,k subscripts to the index. below is the code. Everything works so far. I am wondering how I can apply my bad pixels, subscripted by j,k to a 3-D hyperspectral cube in i,j,k space. Also, for each bad pixel need to take the weighted average of the adjacent good pixels. If two bad pixels in a row need to take 2/3 of the value of the closest good pixel, 1/3 of the value of the farther away good pixel. I need to be able to extrapolate on this process for any number of sequential bad pixels. Any ideas, specific or general, would be greatly appreciated.
badPixelMapName = ['bad_kh_082910' ];
filename = [badPixelMapName '.flt'];
hdrname = [badPixelMapName '.hdr'];
header = readENVIHeaderStruct(hdrname);
nb = header.lines; %in the header, lines are actually number of bands
ns = header.samples;
nl = header.bands;
% create 2D matrix (samples and bands) of bad pixels, with 1's representing bad pixels
fid=fopen([filename]);
fpixel=fread(fid,Inf,'single');
fclose(fid);
badpix = zeros(nb,ns);
cc=0;
for j=1:ns;
for i=1:nb;
cc=cc+1;
badpix(i,j)= fpixel(cc);
end
end
% create linear index of bad pixels
ind = find(badpix);
% assign column(J) & band(K) subscripts to each of the bad pixels
s = [102,640];
[J, K] = ind2sub(s, ind)

답변 (1개)

Sean de Wolski
Sean de Wolski 2011년 6월 2일

카테고리

Help CenterFile Exchange에서 Hyperspectral Image Processing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by