Skip to content

Commit

Permalink
Add RX global.
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanntg committed Apr 6, 2015
1 parent 0aa604b commit 7fc7ecf
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
25 changes: 25 additions & 0 deletions RX_global.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
function img_out = RX_global(Data)
% Perform RX algorithm on global of image

% Dimensions of block
img_size1=size(Data,1);
img_size2=size(Data,2);
channels=size(Data,3);

% Separate block into color channels to calculate K matrix
CC=reshape(Data,[],channels);
K=cov(CC);

% Create mean color column vector
mu=mean(CC)';

for i=1:img_size1
for j=1:img_size2
% Locate center pixel and convert to column vector
r=reshape(Data(i,j,:),channels,[]);

% Run RX detector on center pixel
d(1+i,1+j)=(r-mu)'*K^-1*(r-mu);
end
end
img_out=d;
9 changes: 9 additions & 0 deletions run_script.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ function run_script(scene_file)
fprintf('Color %d...\n', j);

% run four algorithms
% RX GLOBAL
fname = sprintf('output/%s-%d-rx.mat', scene_file, j);
if exist(fname, 'file')
load(fname);
else
img_rx = RX_global(img);
save(fname, 'img_rx');
end

% DWEST
fname = sprintf('output/%s-%d-dwest.mat', scene_file, j);
if exist(fname, 'file')
Expand Down

0 comments on commit 7fc7ecf

Please sign in to comment.