标签:imei 表达式 语法 结果 正整数 核心 space mbr alpha
\[ h(r_k)=n_k \]
\[ p(r_k)=\frac{r_k}{n}=\frac{n_k}{n} \]
h=imhist(f,b)
p=imhist(f,b)/numel(f)
>> f=imread(‘Fig0203(a).tif‘);
>> imhist(f)
bar(horz,v,width)
>> h=imhist(f);
>> h1=h(1:10:256);
>> horz=1:10:256;
>> bar(horz,h1)
>> axis([0 255 0 15000])
>> set(gca,‘xtick‘,0:50:255)
>> set(gca,‘ytick‘,0:2000:15000)
>> h=imhist(f,25);
>> horz=linspace(0,255,25);
>> bar(horz,h)
>> axis([0 255 0 600000])
>> set(gca,‘xtick‘,0:50:255)
>> set(gca,‘ytick‘,0:200000:600000)
axis([horzmin horzmax vertmin vertmax])
axis tight
xlabel(‘text string‘,‘fontsize‘,size)
ylabel(‘text string‘,‘fontsize‘,size)
text(xloc,yloc,‘text string‘,‘fontsize‘,size)
text(‘titlestring‘)
stem(horz,z,‘LineSpec‘,‘fill‘)
符号 | 颜色 | 符号 | 线型 | 符号 | 标记 |
---|---|---|---|---|---|
k | 黑 | - | 实线 | + | 加号 |
w | 白 | -- | 虚线 | o | 圆圈 |
r | 红 | : | 点线 | * | 星号 |
g | 绿 | -. | 点划线 | . | 点 |
b | 蓝 | x | 叉 | ||
c | 青 | s | 方块 | ||
y | 黄 | d | 菱形 | ||
m | 深红 | ^ | 向上三角形 | ||
> | 向右三角形 | ||||
< | 向左三角形 | ||||
P | 五角星 | ||||
h | 六角星 |
>> h=imhist(f,25);
>> horz=linspace(0,255,25);
>> stem(horz,h,‘fill‘)
>> axis([0 255 0 60000])
>> axis([0 255 0 600000])
>> set(gca,‘xtick‘,0:50:255)
>> set(gca,‘ytick‘,0:200000:600000)
plot(horz,z,‘LineSpec‘)
>> hc=imhist(f);
>> plot(hc);
>> axis([0 255 0 60000])
>> set(gca,‘xtick‘,0:50:255)
>> set(gca,‘ytick‘,0:20000:60000)
ylim(‘auto‘)
xlim(‘auto‘)
ylim([ymin ymax])
xlim([xmin xmax])
fplot(fhandle,limits,‘LineSpec‘)
>> fhandle=@tanh;
>> fplot(fhandle,[-2 2],‘:‘)
fplot(fhandle,limits,‘LineSpec‘,n)
\[ s=T(r)=\int^{r}_{0}p_r(w)dw \]
\[
p_s(s)=\begin{cases}1,~0\leq s\leq 1\0,\text{其他}\end{cases}
\]
注:对上述概率密度的补充说明
假设输出灰度级的概率分布函数为\(F_s(y)\),则
\[
\begin{aligned}
F_s(y)&=P(s<y)=P(T(r)<y)\&=P(r<T^{-1}(y))=F_r(T^{-1}(y))=\int_{0}^{T^{-1}(y)}p_r(w)dw
\end{aligned}
\]
因此,\(p_s(y)=F‘_{s}(y)=p_r(T^{-1}(y))\frac{dT^{-1}(y)}{dy}=p_r(x)\frac{dx}{dy}\),其中\(y=\int_{0}^{x}p_r(w)dw\),所以\(\frac{dy}{dx}=p_r(x)\),最终 \(p_s(y)=1\)。
\[ s_k=T(r_k)=\sum_{j=0}^{k}p_r(r_j)=\sum^{k}_{j=0}\frac{n_j}{n} \]
g=histeq(f,nlev)
>> f=imread(‘Fig0208(a).tif‘);
>> subplot(221);imshow(f);xlabel(‘(a)‘);
>> subplot(222);imhist(f);ylim(‘auto‘);xlabel(‘(b)‘);
>> g=histeq(f,256);subplot(223);imshow(g);xlabel(‘(c)‘);
>> subplot(224);imhist(g);ylim(‘auto‘);xlabel(‘(d)‘);
>> hnorm=imhist(f)./numel(f);
>> cdf=cumsum(hnorm);
>> x=linspace(0,1,256);
>> plot(x,cdf)
>> axis([0 1 0 1]);
>> set(gca,‘xtick‘,0:.2:1)
>> set(gca,‘ytick‘,0:.2:1)
>> xlabel(‘输入灰度值‘,‘fontsize‘,9);
>> ylabel(‘输出灰度值‘,‘fontsize‘,9);
\[ s=T(r)=\int_{0}^{r}p_r(w)dw \]
\[ H(z)=\int_{0}^{z}p_z(w)dw=s \]
\[
z=H^{-1}(s)=H^{-1}[T(r)]
\]
***
g=histeq(f,hspec)
>> f=imread(‘Fig0210(a).tif‘);
>> subplot(221);imshow(f);xlabel(‘(a)‘)
>> subplot(222);imhist(f);xlabel(‘(b)‘)
>> f1=histeq(f,256);subplot(223);imshow(f1);xlabel(‘(c)‘)
>> subplot(224);imhist(f1);xlabel(‘(d)‘)
function p=twomodegauss(m1,sig1,m2,sig2,A1,A2,k)
% TWOMODEGAUSS(M1,SIG1,M2.SIG2,A1,A2,K)generates a two-mode, Gaussian-like
% function in the interval [0,1]. P is a 256-element vector normalzied so
% that SUM(P)=1. The mean and standrad deviation of the modes are (M1,SIG1)
% and (M2,SIG2), respectively. A1 and A2 are the amplitude values of the
% two modes. Since the output is normalized, only the relative values of A1
% and A2 are important. K is an offset value that raises the "floor" of the
% function. A good set of values to try is M1=0.15, SIG1=0.05,
% M2=0.75, SIG2=0.05, A1=1, A2=0.07 and K=0.002
c1=A1*(1/((2*pi)^0.5)*sig1);
k1=2*(sig1^2);
c2=A2*(1/((2*pi)^0.5)*sig2);
k2=2*(sig2^2);
z=linspace(0,1,256);
p=k+c1*exp(-((z-m1).^2)./k1)+c2*exp(-((z-m2).^2)./k2);
p=p./sum(p(:));
function p=manualhist
%MANUALHIST Generates a two-mode histogram interactively.
% P=MANUALHIST generates a two-mode histogram using function
% TWOMODEGAUSS(m1,sig1,m2,sig2,A1,A2,k). m1 and m2 are the means of the two
% modes and must be in the range [0,1]. SIG1 and SIG2 are the standard
% deviations of the two modes. A1 and A2 are amplitude values, and k is an
% offset value that raises the floor of the histogram. The number of
% elements in the histogram vector P is 256 and sum(p) is normlized to 1.
% MANUALHIST repeatedly prompts for the paramenters and plots the resulting
% histogram until the user types an ‘x‘ to quit, and then it returns the
% last histogram computed.
%
% A good set of starting values is: (0.15,0.05,0.74,0.05,1,0.07,0.002)
% Initialize.
repeats=true;
quitnow=‘x‘;
% Compute a default histogram in case the user quits before estimating at
% least one histogram.
p = twomodegauss(0.15,0.05,0.75,0.05,1,0.07,0.002);
% Cycle until an x is input.
while repeats
s=input(‘Enter m1, sig1, m2, sig2, A1, A2, k OR x to quit:‘,‘s‘);
if strcmp(s,quitnow)
break;
end
% Convert the input string to a vector of numerical values and verify
% the number of inputs.
v = str2num(s);
if numel(v) ~= 7
disp(‘Incorrect number of inputs.‘)
continue
end
p=twomodegauss(v(1),v(2),v(3),v(4),v(5),v(6),v(7));
% Start a new figure and scale the axes. Specifying only xlim leaves
% ylim on auto.
figure, plot(p)
xlim([0 255])
end
>> g=histeq(f,p);
>> subplot(221);imshow(f);xlabel(‘(a)‘);subplot(222);imhist(f);xlabel(‘(b)‘);
>> subplot(223);imshow(g);xlabel(‘(c)‘);subplot(224);imhist(g);xlabel(‘(d)‘)
g = adapthisteq(f,param1,val1,param2,val2,...)
参数 | 值 |
---|---|
’NumTiles‘ | 根据行和列[r c]指定小片数的正整数的两元素向量。r和c至少是2,小片总数是r*c,默认值是[8 8] |
‘ClipLimit‘ | 范围[0 1]内的标量,指定了对比度增强限制。值越高,对比度也越高。默认值是0.01 |
‘NBins’ | 正整数标量,为建立对比度增强变换而使用的直方图指定堆栈数目。值越高,动态范围越大,同时要付出降低处理速度的代价。默认值是256 |
‘Range’ | 指定输出图像数据范围的字符串: ‘original’—将范围限制为原图像范围[min(f(:)) max(f(:))] |
‘Distribution‘ | 字符串,用于指定图像小片所需的直方图形状: ‘uniform’—平坦的直方图(默认值) ‘rayleigh’—钟形直方图 ‘exponential’—曲线直方图 |
‘Alpha‘ | 用于瑞利分布和指数分布的非负标量,默认值是0.4 |
>> g1=adapthisteq(f);
>> g2=adapthisteq(f,‘NumTiles‘,[25 25]);
>> g3=adapthisteq(f,‘NumTiles‘,[25 25],‘ClipLimit‘,0.05);
>> subplot(221);imshow(f);xlabel(‘(a)‘);subplot(222);imshow(g1);xlabel(‘(b)‘);
>> subplot(223);imshow(g2);xlabel(‘(c)‘);subplot(224);imshow(g3);xlabel(‘(d)‘);
标签:imei 表达式 语法 结果 正整数 核心 space mbr alpha
原文地址:https://www.cnblogs.com/SweetZxl/p/9219650.html