代码解释-Matlab

发布于 2024-10-22 12:36:07 字数 923 浏览 2 评论 0原文

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

问题是我想准确地理解字符分割是如何完成的,在理解它之前我不想使用它。

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

Lucas代码:

    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中执行字符分割

this code suppose to perform character segmentation from an image in Matlab.
the code was given to me by Lucas, so thanks Lucas.

the problem is that I want to understand precisely how the character segmentation is done, I'm don't want to use it before I understand it.

can anyone explain it for me... thanks.

Lucas code:

    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

link: how to perform character segmentation in Matlab

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦与时光遇 2024-10-29 12:36:07
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 

根据尤金的建议,查看提供的链接。

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 

As suggested by Eugene, review the link provided.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文