帮助中心帮助中心
顶帽滤波
J = imtophat(I,SE)
J = imtophat(I,nhood)
示例
J = imtophat(I,SE) 使用结构元素 SE 对灰度或二值图像 I 执行形态学顶帽滤波。顶帽滤波计算图像的形态学开运算(使用 imopen),然后从原始图像中减去结果。
J
I
SE
imopen
J = imtophat(I,nhood) 对图像 I 执行顶帽滤波,其中 nhood 是由 0 和 1 组成的矩阵,用于指定结构元素邻域。
nhood
0
1
此语法等效于 imtophat(I,strel(nhood))。
imtophat(I,strel(nhood))
strel
全部折叠
此示例说明如何使用具有盘形结构元素的顶帽滤波从具有暗背景的图像中去除不均匀的背景亮度。
读取一个图像并显示它。
original = imread('rice.png'); imshow(original)
创建该结构元素。
se = strel('disk',12);
执行顶帽滤波并显示图像。
tophatFiltered = imtophat(original,se); figure imshow(tophatFiltered)
使用 imadjust 来提高结果的可见性。
imadjust
contrastAdjusted = imadjust(tophatFiltered); figure imshow(contrastAdjusted)
输入图像,指定为任意维度的灰度图像或二值图像。
数据类型: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | logical
single
double
int8
int16
int32
uint8
uint16
uint32
logical
offsetstrel
结构元素,指定为单个 strel 对象或 offsetstrel 对象。如果图像 I 的数据类型为 logical,则结构元素必须为平面结构。
结构元素邻域,指定为 0 和 1 组成的矩阵。
示例: [0 1 0; 1 1 1; 0 1 0]
[0 1 0; 1 1 1; 0 1 0]
经过顶帽滤波的图像,以灰度图像或二值图像形式返回。J 与输入图像 I 具有相同的数据类型。
如果图像 I 的维度大于结构元素的维度,则 imtophat 函数会将相同的形态学开运算应用于较高维度上的所有平面。
imtophat
您可以使用此行为对 RGB 图像执行顶帽滤波。为 RGB 图像指定二维结构元素,以便对每个颜色通道分别执行运算。
当指定结构元素邻域时,imtophat 通过 floor((size(nhood)+1)/2) 确定 nhood 的中心元素。
floor((size(nhood)+1)/2)
用法说明和限制:
imtophat 支持 C 代码生成(需要 MATLAB® Coder™)。请注意,如果您选择通用的 MATLAB Host Computer 目标平台,imtophat 生成的代码将使用平台特定的预编译共享库。使用共享库可保留性能上的优化,但适用范围仅限于生成的代码所适用的目标平台。有关详细信息,请参阅Image Processing Toolbox 中代码生成支持的类型。
MATLAB Host Computer
输入图像 I 必须为二维或三维。
图像输入 I 必须为二维或三维图像。
结构元素 SE 必须为编译时常量。
backgroundPool
ThreadPool
此函数完全支持基于线程的环境。有关详细信息,请参阅在基于线程的环境中运行 MATLAB 函数。
gpuArray 输入必须是 uint8 或 logical 类型。
gpuArray
结构元素 SE 必须为平面和二维的。
有关详细信息,请参阅GPU 上的图像处理。
全部展开
imtophat 现在支持基于线程的环境。
imclose
imdilate
imerode
imbothat
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office