使用Matlab进行具有透视畸变的图像文本检测

3

有人知道使用Matlab或任何可用代码从具有透视畸变的图像中检测文本的不同方法吗?OpenCV对于文本检测是否比Matlab更好?

1个回答

2

我认为Matlab对于文本检测(OCR)非常好用。有一些OCR库,其中最重要的是:

Tesseract被认为是目前可用的最准确的开源OCR引擎之一。

我曾经处理过透视畸变的OCR问题,并使用了matlab-tesseract库。

我使用houghlines方法找到图像边缘及其线条,通过旋转图像来解决透视畸变问题。

我将分享我的代码片段,希望它能给你一个关于这个问题的视角。

        function [ output_args ] = rotate_image(  )
         clc;
         close all;
         clear; 

         I = imread("any_images")
         I2 = imcrop(I,[85 150 590 480]);
         I3 = imcrop(I2,[-85 0 440 480]);
         imwrite (I3,'original.tiff', 'Resolution', 300);
        thresh = graythresh(I3);
        Bimage = im2bw(I3, thresh);
        Bimage = edge(Bimage,'sobel');
        [H, T, R] = hough(Bimage);%,'RhoResolution',0.1,'Theta',[-90,0]);
        P  = houghpeaks(H,10);%,'threshold',ceil(0.3*max(H(:))));
        % Find lines and plot them
        lines = houghlines(Bimage,T,R,P);%,'FillGap',100,'MinLength',5);
        figure, imshow(I3), hold on
        max_len = 0;
        for k = 1:length(lines)
            xy = [lines(k).point1; lines(k).point2];
            len = norm(lines(k).point1 - lines(k).point2);
            if ( len > max_len)
                max_len = len;
                xy_long = xy;
            end
        end

    % highlight the longest line segment
    plot(xy_long(:,1),xy_long(:,2),'LineWidth',2,'Color','blue');
    a = -xy_long(1,1) + xy_long(2,1);    
    b = -xy_long(1,2) + xy_long(2,2);

    angle=180-atand(b/a);

    if angle > 180
        angle = angle-180;
    end

    angle
    B = imresize(I3, 2);

   if angle > 90
        B =  imrotate(B, 90 - angle ,'bilinear','crop');
   else 
        B =  imrotate(B, -angle,'bilinear','crop');
   end

   imwrite (B,'rotated_image.tiff', 'Resolution', 300);

 end  

你好,请问能同时提供图片吗?这段代码适用于视频序列吗? - Ann Maria Cherian
不,它不是用于视频序列。它只是从相机中拍摄一个快照。我将编辑我的代码。 - settaratici
我希望这能对你有所帮助。 - settaratici
谢谢先生。您知道如何使用Matlab检测图像的最大稳定极值区域,或者如何将C程序添加到Matlab代码中吗? - Ann Maria Cherian

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接