2016-10-28 684 views
-6

如何计算matlab中图像的log10值和图像的平均值log10? 和图像是graylevel。 例如:在matlab中计算图像的log10

a = imread('image.jpg');

im2bw(a,log10);

我想知道log10如何影响图像?

+0

如果你不能定义图像的log10意味着什么,你为什么要这样做? – MooseBoys

+0

你想达到的最终目标是什么? – mpaskov

+0

范例:'I = imread('cameraman.tif'); I = im2double(I); J = log10(I); imshow(J,[])''。图像较亮(仅在线性拉伸后)和[“对数”](http://homepages.inf.ed.ac.uk/rbf/HIPR2/pixlog.htm)。 J的实际值为负值。 – Rotem

回答

1

1.对数对强度值的影响。

假设你有一个灰度图像。我们使用由matlab提供的cameraman.tif图像。

Img = imread ('cameraman.tif'); 

此图像是UINT8图像(即,它可以在0-255范围的可能的强度值),但实际上该特定图像具有7:3的最小强度值和最大的253,这是有用以证明对数的影响,因为没有0的值(这将导致对数输出中的“负无穷大”)。因此,为了说明取对数时强度发生了什么,我们首先从最小值到最大值取一个线性范围的强度,以及该范围的对数。

Range = double (min (Img(:)) : max (Img(:)));  
LogRange = log10 (Range); 

现在,让我们在[0,1]区间既正常化和情节的范围。

NormalisedRange = mat2gray (Range); 
NormalisedLogRange = mat2gray (LogRange); 

subplot (1, 2, 1); plot (NormalisedRange); axis tight square; title ('Normalised intensity values'); 
subplot (1, 2, 2); plot (NormalisedLogRange); axis tight square; title ('Normalised Log of intensity values'); 

enter image description here

所以,如果你申请一个对数变换,你转移强度“上升”,即你让像素更亮;转换前像素越黑,效果越大。

2.对数的效果在视觉上

让我们看看如何这看起来实际图像上,并且其对数变换(均归一化到[0,1]如上述范围内)。 我们还将检查每幅图像的直方图,即[0,1]范围内每个强度值的频率。

LogImg   = log10 (double (Img)); 
NormalisedImg = mat2gray (Img); 
NormalisedLogImg = mat2gray (LogImg); 

subplot (2, 2, 1); imshow (NormalisedImg, [0, 1]); axis image off; title ('Normalised Image'); 
subplot (2, 2, 2); imshow (NormalisedLogImg, [0, 1]); axis image off; title ('Normalised LogImage'); 
subplot (2, 2, 3); imhist (NormalisedImg); 
subplot (2, 2, 4); imhist (NormalisedLogImg); 

enter image description here

你可以看到转换的效果一直以“亮”的图片上来,特别是,它特别改善了以前较暗区域的对比度(例如,男人的功能现在更清晰)。因为先前较暗的像素现在与较亮的像素相距较近(例如,建筑物和天际线之间的区别现在不那么明显),因为显然,“明亮”区域的对比度已经恶化。

您还可以从直方图中确认强度分布已经在很大程度上向较亮的值转移。