【问题标题】:How to detect rectangle region of one image and merge another image to that region [closed]如何检测一张图像的矩形区域并将另一张图像合并到该区域[关闭]
【发布时间】:2013-12-20 22:29:36
【问题描述】:

我是图像处理的新手,我必须按如下方式处理图像文件 jpeg1:

1.将文本检测为“要检测的文本!”在 jpeg1 上

2.将矩形区域检测为“待检测矩形”,并将另一张图片 seal.jpeg 合并到矩形区域。

我不知道如何用 C# 来实现?

我的图像文件 jpeg1 为:

原始图像 jpeg1 为: 要合并的印章图像为:

【问题讨论】:

    标签: c# opencv image-processing emgucv aforge


    【解决方案1】:

    我可以帮助你的问题2。我不会使用C#,我只是写了一个简单的Matlab代码来提取你想要的矩形区域。我假设 opencv 也有那些图像处理工具箱。请参阅下面的我的 cmets。

    file = 'http://i.stack.imgur.com/zPfdy.jpg';  % Your image provided above
    img = imread(file);
    img = rgb2gray(img);   % convert to gray scale image
    
    % Canny edge detection with threshold of 0.5
    img_edge = edge(img,'canny',0.5);
    
    %Filled image between the edges
    img_filled = imfill(img_edge,'holes');
    
    %Find the filled region with the maximum area
    props = regionprops(img_filled,'Area','PixelList');
    
    max_area = props(1).Area;
    max_count = 1;
    for count=1:size(props,1)
    if(max_area < props(count).Area)
        max_area = props(count).Area;
        max_count = count;
    end
    end
    out_img = zeros([size(img_edge,1) size(img_edge,2)]);
    pixels = props(max_count).PixelList;
    for count=1:size(pixels,1)
        out_img(pixels(count,2),pixels(count,1)) = 1; % fill the maximum filled area
    end
    % % % % % % % % % % % % % % % % % % % % % % % % 
    figure,imagesc(out_img.*double(img))
    

    结果:

    关于文本检测,我认为没有一些先验信息真的很难,因为你涉及的文本太多了。最好知道要检测的文本的大致位置,然后我们可以尝试在更小的区域内查找文本。此外,当您针对某些可能在灰度图像中具有不同强度的特定文本时,调整阈值也很棘手。 顺便说一句,我无法处理您提供的图像,因为您在要检测的文本上添加了一个强矩形区域,这使我很容易提取该区域,而实际上并非如此。

    【讨论】:

    • 谢谢!是否可以将 seal.jpg 合并到矩形?我需要知道矩形位置 (x,y) 才能做到这一点。
    • 是的,您已经有了矩形位置,在我的 matlab 代码中,它只是像素 = props(max_count).PixelList;该像素包括原始图像中最大填充区域内的所有位置。
    猜你喜欢
    • 1970-01-01
    • 2015-01-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-18
    • 1970-01-01
    • 1970-01-01
    • 2014-07-07
    相关资源
    最近更新 更多