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.1 KB
|
Line | |
---|
1 | function DataOut=remove_background(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 | %BACKGROUND LEVEL
|
---|
17 | Atype=class(DataIn.A);
|
---|
18 | A=double(DataIn.A);
|
---|
19 | Backg=zeros(size(A));
|
---|
20 | Aflagmin=sparse(imregionalmin(A));%Amin=1 for local image minima
|
---|
21 | Amin=A.*Aflagmin;%values of A at local minima
|
---|
22 | % local background: find all the local minima in image subblocks
|
---|
23 | sumblock= inline('sum(sum(x(:)))');
|
---|
24 | Backg=blkproc(Amin,[nblock_y nblock_x],sumblock);% take the sum in blocks
|
---|
25 | Bmin=blkproc(Aflagmin,[nblock_y nblock_x],sumblock);% find the number of minima in blocks
|
---|
26 | Backg=Backg./Bmin; % find the average of minima in blocks
|
---|
27 | B=imresize(Backg,size(A),'bilinear');% interpolate to the initial size image
|
---|
28 | ImPart=(A-B);
|
---|
29 | DataOut.A=ImPart.*(ImPart>threshold);
|
---|
30 | DataOut.A=feval(Atype,DataOut.A); |
---|
Note: See
TracBrowser
for help on using the repository browser.