【问题标题】:Code explanation - Matlab代码解释 - Matlab
【发布时间】:2014-09-08 11:43:32
【问题描述】:

此代码假设在 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

链接:how to perform character segmentation in Matlab

【问题讨论】:

标签: matlab image-segmentation


【解决方案1】:
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 的建议,查看提供的链接。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-14
    • 1970-01-01
    • 2015-03-23
    • 2011-07-12
    相关资源
    最近更新 更多