%    Coherent Noise Detection

function [hist_image, EDGES, final_EDGES] = coherent_noise(image,std_mult)

%    This routine defines blank, noisy images that have hist_images that are not
%    single-moded (e.g. like Gaussian or Poisson noise) as having coherent
%    noise, i.e. artifacts in the image that are not random and not necessarily repetitive.

%   This is useful for determing if an imaging sensor is working properly
%   by imaging a uniform scene/target and confirming that the only signal
%   variations are due to sensor noise.

%   The routine returns the locations of the modes in the hist_image
%    Variable "ignore" is the minimum mode height to be recognized.
%    Any frequency of occurrence smaller than this value is considered noise.

[hist_image,EDGES,BIN] = histcounts(image);
figure(100)
plot(EDGES(2:end),hist_image)

length_of_hist_image=length(hist_image);
for i=1:length_of_hist_image-2,
        coherent(i)=0;
        A=hist_image(i+2)-hist_image(i+1);
        B=hist_image(i+1)-hist_image(i);

%        If the hist_image indicates a fall from a peak designate this point as a mode

    if  ((A<0) & (B>=0)), coherent(i)=1;
    end;
end;
[mode]=find(coherent);

%    Make sure that local peaks are not simply noise and that modes are separated by a minimum distance in terms of multiples of the image standard deviation.

std_image=std2(image);
min_separation=std_mult*std_image;
EDGES(mode(1))=EDGES(mode(2));
bin_index=0;
for bin=2:length(mode),
    if(EDGES(mode(bin))-EDGES(mode(bin-1)))>min_separation,
        bin_index=bin_index+1;
        final_mode(bin_index)=bin_index;
        final_EDGES(bin_index)=EDGES(mode(bin));
    end       
end




Serious Science LLC
           Where science fiction becomes fact.
Navigation
Home
Publications
Handy Equations
Code
Personnel
Contact
Imagery Examples
Other Remote Sensing Links