【发布时间】:2013-12-20 22:29:36
【问题描述】:
我是图像处理的新手,我必须按如下方式处理图像文件 jpeg1:
1.将文本检测为“要检测的文本!”在 jpeg1 上
2.将矩形区域检测为“待检测矩形”,并将另一张图片 seal.jpeg 合并到矩形区域。
我不知道如何用 C# 来实现?
我的图像文件 jpeg1 为:
原始图像 jpeg1 为: 要合并的印章图像为:
【问题讨论】:
标签: c# opencv image-processing emgucv aforge
我是图像处理的新手,我必须按如下方式处理图像文件 jpeg1:
1.将文本检测为“要检测的文本!”在 jpeg1 上
2.将矩形区域检测为“待检测矩形”,并将另一张图片 seal.jpeg 合并到矩形区域。
我不知道如何用 C# 来实现?
我的图像文件 jpeg1 为:
原始图像 jpeg1 为: 要合并的印章图像为:
【问题讨论】:
标签: c# opencv image-processing emgucv aforge
我可以帮助你的问题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))
结果:
关于文本检测,我认为没有一些先验信息真的很难,因为你涉及的文本太多了。最好知道要检测的文本的大致位置,然后我们可以尝试在更小的区域内查找文本。此外,当您针对某些可能在灰度图像中具有不同强度的特定文本时,调整阈值也很棘手。 顺便说一句,我无法处理您提供的图像,因为您在要检测的文本上添加了一个强矩形区域,这使我很容易提取该区域,而实际上并非如此。
【讨论】: