【问题标题】:text detection from an image with perspective distortion using matlab使用matlab从具有透视失真的图像中检测文本
【发布时间】:2015-08-19 09:09:44
【问题描述】:

任何人都可以知道使用matlab从具有透视失真的图像中检测文本的不同方法吗?或者任何代码都可用。opencv在文本检测方面是否优于matlab

【问题讨论】:

    标签: matlab image-processing ocr matlab-cvst


    【解决方案1】:

    我认为,matlab 对文本检测 (ocr) 有好处。 有几个 ocr 库。最重要的是:

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

    我研究过带有透视失真的 ocr,我使用 matlab-tesseract 库。

    我通过使用houghlines 方法查找图像边框及其线条来处理旋转图像的透视失真问题。

    我将分享我的代码 sn-p,希望它能让您对这个问题有所了解

            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  
    

    【讨论】:

    • hai 你能把图片也给我吗 这个代码是否适用于视频序列
    • 不,它不适用于视频序列。它只是从相机中选择快照。我将编辑我的代码。
    • 希望对您有所帮助
    • 谢谢先生..您知道如何使用matlab检测图像的最大稳定极值区域或如何将c程序添加到matlab代码中
    猜你喜欢
    • 2021-08-30
    • 2022-09-27
    • 2018-07-13
    • 2017-06-25
    • 2013-12-27
    • 2012-04-25
    • 2015-12-24
    • 2021-10-04
    相关资源
    最近更新 更多