目录
2.实战项目一:利用imfindcircles()函数检测和测量图像中的圆形目标
1.基本图像导入、处理和导出
Basic Image Import, Processing, and Export- MATLAB & SimulinkThis example shows how to read an image into the workspace, adjust the contrast in the image, and then write the adjusted image to a file.https://www.mathworks.com/help/releases/R2021b/images/image-import-and-export.html以下是输入的缺陷检测图片1.jpg(左),和经过histeq(直方图均衡使强度值扩展分布到了图像的完整范围内)函数提高对比度的2.jpg(右)。
I = imread("1.jpg");
whos I % 使用 whos 命令,检查 imread 函数如何在工作区中存储图像数据。
% 调用 imhist 函数创建直方图。
% 请在调用 imhist 之前使用 figure 命令,这样直方图就不会覆盖当前图窗窗口中显示的图像 I。
imhist(I)
I2 = histeq(I); % 使用 histeq 函数提高图像的对比度
imshow(I2)
imwrite(I2, '2.jpg'); % 使用 imwrite 函数,将刚刚经过调整的图像 I2 写入磁盘文件
imfinfo('2.jpg') % imfinfo 函数返回文件中图像的相关信息
2.实战项目一:利用imfindcircles()函数检测和测量图像中的圆形目标
Detect and Measure Circular Objects in an Image- MATLAB & Simulink ExampleThis example shows how to automatically detect circular objects in an image and visualize the detected circles.https://www.mathworks.com/help/releases/R2021b/images/detect-and-measure-circular-objects-in-an-image.htmlimfindcircles()使用基于圆形 Hough 变换 (CHT) 的算法在图像中寻找圆形。之所以使用这种方法,是因为当存在噪声、遮挡和变化的光照条件时该方法表现稳健。
有关imfindcircles()的详细信息,请参阅帮助文档: