【问题标题】:Object extraction for a low contrast image低对比度图像的对象提取
【发布时间】:2015-03-16 07:07:12
【问题描述】:

我有一张对比度非常低的图像,我想从中提取一个文本对象。由于它的对比度低,我尝试了几种方法,但没有一种方法能给我带来令人满意的结果。我使用watershed 提取文本对象,但由于对比度差,提取不成功。

watershed 我的程序是:

I_cropped=imread(strcat('C:\Id\',currentfilename));
I_cropped = rgb2gray(I_cropped);
I_eq = histeq(I_cropped);  
figure,imshow(I_eq);
bw = im2bw(I_eq, graythresh(I_eq));
bw2 = imfill(bw,'holes');
bw3 = imopen(bw2, ones(5,5));
bw4 = bwareaopen(bw3, 40);
bw = im2bw(I_eq, graythresh(I_eq));
figure,imshow(bw);
mask_em = imextendedmax(I_eq, 30);
mask_em = imclose(mask_em, ones(5,5));
mask_em = imfill(mask_em, 'holes');
mask_em = bwareaopen(mask_em, 40);
figure,imshow(mask_em);
I_eq_c = imcomplement(I_eq);
figure,imshow(I_eq_c);
I_mod = imimposemin(I_eq_c, ~bw4 | mask_em);
figure,imshow(I_mod);
L = watershed(I_mod);
figure,imshow(label2rgb(L));

我应用了laplacian滤镜并增强了边缘,但效果不佳。

我的目标是提取文本对象。对于这种低对比度的图像,我应该尝试什么方法?

图片附上:

【问题讨论】:

  • 提取文本对象”是什么意思?你想得到一个包含所有数字的区域,将数字分开,还是得到一个与图像上的数字相对应的数字?请更具体地说明所需的输出。

标签: matlab image-processing text-extraction


【解决方案1】:

这是一种方法。

首先对图像应用具有大内核的中值滤波器以去除异常值,然后应用阈值转换为二值图像。请注意,使用过滤器的内核大小会改变您需要使用的阈值级别。试一试以查看输出的变化。

然后反转图像并应用regionprops 来检测图像中的物体。之后进行一些数学运算来推断 x 和 y 原点(定义左上角)以及包围图像中所有字母的大边界框的宽度和长度。

代码如下:

clear
clc

close all

Im = rgb2gray(imread('Imtext.png'));

%// Apply median filter to remove outliers
Im = medfilt2(Im,[9 9]);

%// Clear borders and apply threshold, then invert image
ImBW = imclearborder(~(im2bw(Im,.55)));

%// Find bounding boxes to delineate text regions.
S = regionprops(ImBW,'BoundingBox');

%// Concatenate all bounding boxes and obtain x,y, width and length of big
%// bounding box enclosing everything
bb = cat(1,S.BoundingBox);

LargeBB_x = min(bb(:,1));
LargeBB_y = min(bb(:,2));

LargeBB_height = max(bb(:,4));

%// Find last column in which pixel value is 1; that's the end 
%// of the bounding box.
[~,ic] = find(ImBW==1);
MaxCol = max(ic(:));

LargeBB_width = MaxCol-LargeBB_x;

%// Display boxes
imshow(ImBW)
hold on
    rectangle('Position',[LargeBB_x LargeBB_y LargeBB_width LargeBB_height],'EdgeColor','r','LineWidth',2) 

hold off

还有输出:

或者用原图:

【讨论】:

  • 太棒了!祝你好运:)
  • 有没有办法可以进一步分割单个数字?
  • 嗯,您可以应用图像腐蚀或其他形态学操作来细化字母...查看bwmorphimerode
猜你喜欢
  • 1970-01-01
  • 2015-02-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-03
  • 2016-11-30
  • 2020-12-16
  • 2020-05-09
相关资源
最近更新 更多