Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 其它 > 资料存档
资料存档 资料存档
回复
 
主题工具 显示模式
旧 2019-12-14, 20:13   #1
poster
高级会员
 
注册日期: 2019-11-21
帖子: 3,006
声望力: 66
poster 正向着好的方向发展
帖子 代码说明-Matlab

该代码假设要在Matlab中对图像进行字符分割。代码是卢卡斯给我的,所以谢谢卢卡斯。

问题是我想精确地了解字符分割的方式,在理解之前我不想使用它。

谁能为我解释一下...谢谢。

卢卡斯代码:

clear all; close all; I = imread('plate.jpg'); BW = im2bw(I, 0.9); BW = ~BW; stats = regionprops(BW); for index=1:length(stats) if stats(index).Area > 200 && stats(index).BoundingBox(3)*stats(index).BoundingBox(4) < 30000 x = ceil(stats(index).BoundingBox(1)) y= ceil(stats(index).BoundingBox(2)) widthX = floor(stats(index).BoundingBox(3)-1) widthY = floor(stats(index).BoundingBox(4)-1) subimage(index) = {BW(y:y+widthY,x:x+widthX,:)}; figure, imshow(subimage{index}) end end 链接: 如何在Matlab中执行字符分割



回答:

clear all; % clear out workspace memory close all; % close all figures I = imread('plate.jpg'); % load image jpg into I BW = im2bw(I, 0.9); % convert color image to black and white image BW = ~BW; % swap black and white stats = regionprops(BW); % compute 'Area', 'Centroid', and 'BoundingBox' measurements. % The regionprops operation is what "cuts up" the image into possible pieces of interest. % You will need to develop your own code for processing. for index=1:length(stats) % if the stats of the region meet a certain criteria if stats(index).Area > 200 && stats(index).BoundingBox(3)*stats(index).BoundingBox(4) < 30000 x = ceil(stats(index).BoundingBox(1)) y= ceil(stats(index).BoundingBox(2)) widthX = floor(stats(index).BoundingBox(3)-1) widthY = floor(stats(index).BoundingBox(4)-1) % extract a subimage from the original image and show it. subimage(index) = {BW(y:y+widthY,x:x+widthX,:)}; figure, imshow(subimage{index}) end 根据Eugene的建议,查看提供的链接。



更多&回答...
poster 当前离线   回复时引用此帖
回复


发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛禁用 表情符号
论坛启用 [IMG] 代码
论坛启用 HTML 代码



所有时间均为北京时间。现在的时间是 22:50


Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.