如何在Matlab中水平分割图像的字符

时间:2018-06-02 08:49:06

标签: matlab image-processing image-segmentation

我有以下图片 enter image description here

我编写了一个用于分割图像字符的代码。

close all;clear;clc;

main_img = imread('Capture.JPG');
main_img = 1 - im2bw(main_img);
main_img = bwareaopen(main_img, 50);
[obj_seg_img ,num_object] = bwlabel(main_img);
CC = bwconncomp(main_img);
S = regionprops(CC,'Centroid');
stats = regionprops(CC,'Image');
figure;
numb = size(stats,1);

figure;
for i = 1 : size(stats,1)
     cur_obj = stats(i).Image;
        img1_b = cur_obj;
        img1 = normalize({img1_b});
        img = img1{1}(:);
        subplot(1,numb,i);
        imshow(stats(i).Image);
end

但它会像下面的图像一样垂直提取数字,顺序为7,1,2,8,3,9,4,5,6 enter image description here

但我希望水平分段1,2,3,4,5,6,7,8,9。我该怎么做? 注意:我尝试通过imrotete旋转图像(img,90),但它对我的一些图像不起作用

0 个答案:

没有答案
相关问题