Changeset 906 for trunk/src/transform_field
- Timestamp:
- May 31, 2015, 7:49:31 PM (10 years ago)
- Location:
- trunk/src/transform_field
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/transform_field/ima_erode_particles.m
r899 r906 35 35 36 36 %parameters 37 radius= 2;38 SE=strel('disk', 2);37 radius=4; 38 SE=strel('disk',radius); 39 39 %--------------------------------------------------------- 40 40 DataOut=DataIn;%default … … 44 44 return 45 45 end 46 46 [npy,npx]=size(DataIn.A); 47 [X,Y]=meshgrid(1:npx,1:npy); 47 48 %BACKGROUND LEVEL 48 49 Atype=class(DataIn.A); 49 DataOut.A=imerode(DataIn.A,SE); 50 %SE=ones(4); 51 Aerode=imerode(DataIn.A,SE); 52 Aflagmin=find(DataIn.A==Aerode); 53 % Backg=zeros(size(A)); 54 %Aflagmin=imregionalmin(DataIn.A);%Amin=1 for local image minima 55 Xmin=X(Aflagmin); 56 Ymin=Y(Aflagmin); 57 Amin=double(DataIn.A(Aflagmin)); 58 F = TriScatteredInterp([Xmin Ymin], Amin); 59 DataOut.A=F(X,Y); 60 50 61 % DataOut.A=feval(Atype,DataOut.A); 51 62 -
trunk/src/transform_field/ima_remove_background.m
r897 r906 27 27 %======================================================================= 28 28 29 function DataOut=remove_background(DataIn )29 function DataOut=remove_background(DataIn,Param) 30 30 %------------------------------------------------------------------------ 31 DataOut=[]; %default output field 32 if strcmp(DataIn,'*') 31 %% request input parameters 32 if isfield(DataIn,'Action') && isfield(DataIn.Action,'RUN') && isequal(DataIn.Action.RUN,0) 33 prompt = {'radius'}; 34 dlg_title = 'get the disk radius (pixels) used to calculate the regional minimum'; 35 num_lines= 1; 36 def = { '4'}; 37 if isfield(Param,'TransformInput')&&isfield(Param.TransformInput,'DiskRadius') 38 def={num2str(Param.TransformInput.DiskRadius)}; 39 end 40 answer = inputdlg(prompt,dlg_title,num_lines,def); 41 DataOut.TransformInput.DiskRadius=str2num(answer{1}); 42 return 43 end 44 if ~isfield(DataIn,'A') 45 DataOut.Txt='remove_particles only valid for input images'; 46 return 47 end 48 if ~exist('imerode','file'); 49 DataOut.Txt='the function imerode from the image processing toolbox is needed'; 33 50 return 34 51 end 35 52 36 %parameters 37 threshold=200 38 nblock_x=30;%size of image subblocks for analysis 39 nblock_y=30; 40 %--------------------------------------------------------- 53 SE=strel('disk',Param.TransformInput.DiskRadius); 54 %--------------------------------------------------------- 41 55 DataOut=DataIn;%default 56 57 [npy,npx]=size(DataIn.A); 58 [X,Y]=meshgrid(1:npx,1:npy); 42 59 43 60 %BACKGROUND LEVEL 44 61 Atype=class(DataIn.A); 45 A=double(DataIn.A); 46 Backg=zeros(size(A)); 47 Aflagmin=sparse(imregionalmin(A));%Amin=1 for local image minima 48 Amin=A.*Aflagmin;%values of A at local minima 49 % local background: find all the local minima in image subblocks 50 sumblock= inline('sum(sum(x(:)))'); 51 Backg=blkproc(Amin,[nblock_y nblock_x],sumblock);% take the sum in blocks 52 Bmin=blkproc(Aflagmin,[nblock_y nblock_x],sumblock);% find the number of minima in blocks 53 Backg=Backg./Bmin; % find the average of minima in blocks 54 B=imresize(Backg,size(A),'bilinear');% interpolate to the initial size image 55 ImPart=(A-B); 56 DataOut.A=ImPart; 57 %DataOut.A=ImPart.*(ImPart>threshold); 62 Aerode=imerode(DataIn.A,SE); 63 Aflagmin=find(DataIn.A==Aerode); 64 Xmin=X(Aflagmin); 65 Ymin=Y(Aflagmin); 66 Amin=double(DataIn.A(Aflagmin)); 67 F = TriScatteredInterp([Xmin Ymin], Amin); 68 DataOut.A=double(DataOut.A)-F(X,Y); 58 69 DataOut.A=feval(Atype,DataOut.A); 70 71 %BACKGROUND LEVEL 72 % Atype=class(DataIn.A); 73 % A=double(DataIn.A); 74 % Backg=zeros(size(A)); 75 % Aflagmin=sparse(imregionalmin(A));%Amin=1 for local image minima 76 % Amin=A.*Aflagmin;%values of A at local minima 77 % % local background: find all the local minima in image subblocks 78 % sumblock= inline('sum(sum(x(:)))'); 79 % Backg=blkproc(Amin,[nblock_y nblock_x],sumblock);% take the sum in blocks 80 % Bmin=blkproc(Aflagmin,[nblock_y nblock_x],sumblock);% find the number of minima in blocks 81 % Backg=Backg./Bmin; % find the average of minima in blocks 82 % B=imresize(Backg,size(A),'bilinear');% interpolate to the initial size image 83 % ImPart=(A-B); 84 % DataOut.A=ImPart; 85 % %DataOut.A=ImPart.*(ImPart>threshold); 86 % DataOut.A=feval(Atype,DataOut.A); -
trunk/src/transform_field/ima_remove_particles.m
r897 r906 27 27 %======================================================================= 28 28 29 function DataOut=ima_remove_particles(DataIn )29 function DataOut=ima_remove_particles(DataIn,Param) 30 30 %------------------------------------------------------------------------ 31 DataOut=[]; %default output field 32 if strcmp(DataIn,'*') 31 %% request input parameters 32 if isfield(DataIn,'Action') && isfield(DataIn.Action,'RUN') && isequal(DataIn.Action.RUN,0) 33 prompt = {'radius'}; 34 dlg_title = 'get the disk radius (pixels) used to calculate the regional minimum'; 35 num_lines= 1; 36 def = { '4'}; 37 if isfield(Param,'TransformInput')&&isfield(Param.TransformInput,'DiskRadius') 38 def={num2str(Param.TransformInput.DiskRadius)}; 39 end 40 answer = inputdlg(prompt,dlg_title,num_lines,def); 41 DataOut.TransformInput.DiskRadius=str2num(answer{1}); 33 42 return 34 35 43 end 36 37 %parameters38 threshold=200;39 nblock_x=10;%size of image subblocks for analysis40 nblock_y=10;41 %---------------------------------------------------------42 DataOut=DataIn;%default43 44 44 if ~isfield(DataIn,'A') 45 45 DataOut.Txt='remove_particles only valid for input images'; 46 46 return 47 47 end 48 if ~exist('imerode','file'); 49 DataOut.Txt='the function imerode from the image processing toolbox is needed'; 50 return 51 end 48 52 53 SE=strel('disk',Param.TransformInput.DiskRadius); 54 %--------------------------------------------------------- 55 DataOut=DataIn;%default 56 57 [npy,npx]=size(DataIn.A); 58 [X,Y]=meshgrid(1:npx,1:npy); 49 59 %BACKGROUND LEVEL 50 60 Atype=class(DataIn.A); 51 A=double(DataIn.A); 61 %SE=ones(4); 62 Aerode=imerode(DataIn.A,SE); 63 Aflagmin=find(DataIn.A==Aerode); 52 64 % Backg=zeros(size(A)); 53 Aflagmin=sparse(imregionalmin(A));%Amin=1 for local image minima 54 Amin=A.*Aflagmin;%values of A at local minima 55 % local background: find all the local minima in image subblocks 56 sumblock= inline('sum(sum(x(:)))'); 57 Backg=blkproc(Amin,[nblock_y nblock_x],sumblock);% take the sum in blocks 58 Bmin=blkproc(Aflagmin,[nblock_y nblock_x],sumblock);% find the number of minima in blocks 59 Backg=Backg./Bmin; % find the average of minima in blocks 60 B=imresize(Backg,size(A),'bilinear');% interpolate to the initial size image 61 DataOut.A=B; 62 % ImPart=(A-B); 63 % ImPart=ImPart.*(ImPart>threshold); 64 % DataOut.A=A-ImPart;% 65 %Aflagmin=imregionalmin(DataIn.A);%Amin=1 for local image minima 66 Xmin=X(Aflagmin); 67 Ymin=Y(Aflagmin); 68 Amin=double(DataIn.A(Aflagmin)); 69 F = TriScatteredInterp([Xmin Ymin], Amin); 70 DataOut.A=F(X,Y); 65 71 DataOut.A=feval(Atype,DataOut.A); 66 72
Note: See TracChangeset
for help on using the changeset viewer.