source: trunk/src/transform_field/im_levels.m @ 40

Last change on this file since 40 was 40, checked in by sommeria, 11 years ago

-relabel_i_j added to the svn (relabel an image series with two indices)
-Menu projection Object added to uvmat, rationalizes the call of projection objects (to improve yet)
-get_plot_handles: modified in relationwith the Menu projection object
-mouse_down: corrected in relation with previous change in field transforms
-transform_field functions added to the svn
-set_object and keyboard_callback: cleaning

File size: 1.2 KB
Line 
1function DataOut=im_levels(DataIn,Calib)
2%-----------------------------------------------
3%parameters
4np=30
5%---------------------------------------------------------
6DataOut=DataIn;%default
7
8B=double(DataIn.A(:,:,1));
9windowsize=round(min(size(B,1),size(B,2))/20);
10windowsize=floor(windowsize/2)*2+1;
11ix=[1/2-windowsize/2:-1/2+windowsize/2];%
12%del=np/3;
13%fct=exp(-(ix/del).^2);
14fct2=cos(ix/((np-1)/2)*pi/2);
15%Mfiltre=(ones(5,5)/5^2);
16%Mfiltre=fct2';
17Mfiltre=fct2'*fct2;
18Mfiltre=Mfiltre/(sum(sum(Mfiltre)));
19
20C=filter2(ones(windowsize)/windowsize^2,B);
21C(:,1:windowsize)=C(:,windowsize)*ones(1,windowsize);
22C(:,end-windowsize+1:end)=C(:,end-windowsize+1)*ones(1,windowsize);
23C(1:windowsize,:)=ones(windowsize,1)*C(windowsize,:);
24C(end-windowsize+1:end,:)=ones(windowsize,1)*C(end-windowsize,:);
25C=tanh(B./(2*C));
26[n,c]=hist(reshape(C,1,[]),100);
27% figure;plot(c,n);
28
29[m,i]=max(n);
30c_max=c(i);
31[dummy,index]=sort(abs(c-c(i)));
32n=n(index);
33c=c(index);
34i_select = find(cumsum(n)<0.95*sum(n));
35if isempty(i_select)
36    i_select = 1:length(c);
37end
38c_select=c(i_select);
39n_select=n(i_select);
40cmin=min(c_select);
41cmax=max(c_select);
42C=(C-cmin)/(cmax-cmin)*256;
43DataOut.AA=uint8(C);
44
45
46
47DataOut.A=uint8(C);
Note: See TracBrowser for help on using the repository browser.