Bad Pixel Replacement
11 views (last 30 days)
Show older comments
[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)
0 Comments
Answers (1)
See Also
Categories
Find more on Hyperspectral Image Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!