matlab - 使用matlab从具有透视失真的图像中进行文本检测

标签 matlab image-processing ocr matlab-cvst

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

最佳答案

我认为,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  

关于matlab - 使用matlab从具有透视失真的图像中进行文本检测,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30649211/

相关文章:

java - 使用 Java 或 .NET 库对 ColdFusion 中的 PDF 执行光学字符识别?

Matlab scatterhist plots - 只显示一个直方图

python - OpenCV 找到彩色圆圈和位置值 Python

image - 请告诉我有关此计算机视觉任务的信息

android - Microblink 识别器设置 RegexParserSettings

neural-network - 如何制作 OCR 程序?

matlab - Java 3D : Scenegraph disappears from some viewing positions

matlab - 扩展matlab中的subplot函数

matlab - 寻找信息量最大的图像

Python OpenCV 调整大小(插值)