From 7fc7ecf1f7f8e7b868aeae39cf8cc5a58a6908b8 Mon Sep 17 00:00:00 2001 From: Nathan Perkins Date: Mon, 6 Apr 2015 09:42:17 -0400 Subject: [PATCH] Add RX global. --- RX_global.m | 25 +++++++++++++++++++++++++ run_script.m | 9 +++++++++ 2 files changed, 34 insertions(+) create mode 100644 RX_global.m diff --git a/RX_global.m b/RX_global.m new file mode 100644 index 0000000..2b38dab --- /dev/null +++ b/RX_global.m @@ -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; diff --git a/run_script.m b/run_script.m index 7352ac5..afebec2 100644 --- a/run_script.m +++ b/run_script.m @@ -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')