自己编写了一个matlab的小程序,用来计算球形纳米粒子的直径,希望对大家有用。这个程序非常简单,只要设置5个参数:前两个是输入和输出文件的路径和名称;第三个是一个数据的门槛,适当的数值可以把纳米粒子和背景区分开;第四个是TEM照片中标尺的大小,单位nm;第五个是估计图中有多少个纳米粒子。详细程序: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This programme can select and calculate the size of nanoparticles in TEM picture. % How to use: % 1. Input parameters in 'Parameter Setting Part' according to the instructions % 2. Run program % 3. Select start and end of the ruler, click two times at different place % 4. After a flash, click the center of nanoparticles % 5. The Diameter of nanoparticles is in outfile % Note: nanoparticles are regarded as a spherical ball % Built by Xiaochun Zhou, 05-22-2009 % Enjoy it! Any questions? Ask zxczxc0417@163.com . %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear;clc; %------------ Parameter Setting Part -----------------% infile='E:\Document\data\011509\4-5.jpg'; % TEM figure outfile='E:\Document\data\011509\4-5.txt'; % Output file of Diameter thresh = 120; % for figure dx = 100; % nm, size of the ruler n_p = 5; % how many particles in your figure %------------ Parameter Setting Part -----------------% = imread(infile); = size( x ); x = x(:,:,1); x = double(x); for i = 1:heigth for j = 1:width if x(i,j) thresh x(i,j) = 0; else x(i,j) = 100; end end end msgbox('select the start and end point ruler in your map!!!!!!!!!!!!'); pause(3); imshow(x); = ginput(2); dxdy = ( dx/abs( xa(1) - xa(2) ) ) * ( dx/abs( xa(1) - xa(2) ) ); % msgbox( ); close imshow(x); for i = 1:n_p % NP number = ginput (1); xa = round(xa); yb = round(yb); area(i) = 0; for j = 0:1000 if x(yb,xa +j) thresh/2 break end for yi = 0:1000 if x(yb + yi,xa +j) thresh/2 break else area(i) = area(i) + 1; end end for yi = 1:1000 if x(yb - yi,xa +j) thresh/2 break else area(i) = area(i) + 1; end end end for j = 1:1000 if x(yb,xa -j) thresh/2 break end for yi = 0:1000 if x(yb + yi,xa - j) thresh/2 break else area(i) = area(i) + 1; end end for yi = 1:1000 if x(yb - yi,xa - j) thresh/2 break else area(i) = area(i) + 1; end end end end close for i = 1:n_p % NP number area(i) = area(i) * dxdy; diameter1(i) = 2*sqrt( area(i)/3.14159 ); end diameter1 = diameter1'; dlmwrite(outfile,diameter1);