Last change
on this file since 567 was
557,
checked in by sommeria, 12 years ago
|
functions updated to fit with new conventions
|
File size:
1.2 KB
|
Line | |
---|
1 | function DataOut=remove_particles(DataIn)
|
---|
2 | %-----------------------------------------------
|
---|
3 | %% set GUI config: no action defined
|
---|
4 | DataOut=[]; %default output field
|
---|
5 | if strcmp(DataIn,'*')
|
---|
6 | return
|
---|
7 | end
|
---|
8 |
|
---|
9 | %parameters
|
---|
10 | threshold=200;
|
---|
11 | nblock_x=30;%size of image subblocks for analysis
|
---|
12 | nblock_y=30;
|
---|
13 | %---------------------------------------------------------
|
---|
14 | DataOut=DataIn;%default
|
---|
15 |
|
---|
16 | if ~isfield(DataIn,'A')
|
---|
17 | DataOut.Txt='remove_particels only valid for input images';
|
---|
18 | return
|
---|
19 | end
|
---|
20 |
|
---|
21 | %BACKGROUND LEVEL
|
---|
22 | Atype=class(DataIn.A);
|
---|
23 | A=double(DataIn.A);
|
---|
24 | Backg=zeros(size(A));
|
---|
25 | Aflagmin=sparse(imregionalmin(A));%Amin=1 for local image minima
|
---|
26 | Amin=A.*Aflagmin;%values of A at local minima
|
---|
27 | % local background: find all the local minima in image subblocks
|
---|
28 | sumblock= inline('sum(sum(x(:)))');
|
---|
29 | Backg=blkproc(Amin,[nblock_y nblock_x],sumblock);% take the sum in blocks
|
---|
30 | Bmin=blkproc(Aflagmin,[nblock_y nblock_x],sumblock);% find the number of minima in blocks
|
---|
31 | Backg=Backg./Bmin; % find the average of minima in blocks
|
---|
32 | B=imresize(Backg,size(A),'bilinear');% interpolate to the initial size image
|
---|
33 | ImPart=(A-B);
|
---|
34 | ImPart=ImPart.*(ImPart>threshold);
|
---|
35 | DataOut.A=A-ImPart;%
|
---|
36 | DataOut.A=feval(Atype,DataOut.A);
|
---|
37 |
|
---|
Note: See
TracBrowser
for help on using the repository browser.