matlab图像示例笔记1
对比度
histogram 直方图
Precede the call to imhist
with the figure
command so that the histogram does not overwrite the display of the image I in the current figure window.
To see the distribution of intensities in the image, create a histogram by calling the imhist
function.
输入图片,图片要求为灰度图或者二值图 imhist
F=imread('test.jpg');
I=rgb2gray(F);
[count,x]=imhist(I,30)
% 获取直方图的横坐标和纵坐标,即各个像素级,以及每个像素级上的像素出现的次数
figure;
subplot(221);imhist(I,2);
subplot(222);imhist(I,5);
subplot(223);imhist(I,10);
subplot(224);imhist(I);
figure;
subplot(121); imhist(I,10)
[count,x] = imhist(I,10)
subplot(122);stem(x,count);
stem
绘制离散序列数据
Improve the contrast
in an image, using the histeq function
. The toolbox includes several other functions that perform contrast adjustment, including imadjust
and adapthisteq
, and interactive tools such as the Adjust Contrast tool, available in the Image Viewer
adjust the contrast
灰度直方图均衡化histeq
Correct Nonuniform Background Illumination and Analyze Foreground Objects
nonuniform
strel()
Morphological structuring element
J = imopen(I,SE)
performs morphological opening on the grayscale or binary image I, returning the opened image, J. SE is a single structuring element object returned by the strel or offsetstrel functions
. The morphological open operation is an erosion followed by a dilation, using the same structuring element for both operations.
surf
曲面图全页折叠
语法
surf(X,Y,Z)
surf(X,Y,Z,C)
f1=imadjust(f,[low_in high_in],[low_out high_out],gamma)
该函数的意义如图1所示,把图像f 灰度变换到新图像f1的过程中,f 中灰度值低于low_in
的像素点在f1中灰度值被赋值为low_out
,同理,f中灰度值高于high_in
的像素点变换到f1时其灰度值也被赋值为high_out
;
J=imadjust(I,[0.2 0.5],[0 1])
原图像灰度范围为0-255,程序将小于255×0.2的灰度值设置为0,将大于255×0.5的灰度值设置为255
饱和度取决于该色中含色成分和消色成分(灰色)的比例
比度指的是一幅图像中明暗区域最亮的白和最暗的黑之间不同亮度层级的测量,差异范围越大代表对比越大
Use the imbinarize function
to convert the grayscale image into a binary image
Remove background noise
from the image with the bwareaopen function
.
F = false(sz1,…,szN) 是由逻辑值“0”组成的 sz1×…×szN 数组,其中 sz1,…,szN 表示每个维度的大小。例如,false(2,3) 返回由逻辑值“0”组成的 2×3 数组。