低对比度图像分割 [英] Low contrast image segmentation

查看:487
本文介绍了低对比度图像分割的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对低对比度图像分割有问题。
任务是找到表面缺陷。它们是可见的(缺陷总是暗区)但图像的对比度非常低。
以下两个样本。

I have problem with low contrast image segmentation. Task is to find surface defects. They are visible (defects are always dark areas) but the contrast of image is very low. Below two samples.


我试过增强对比然后阈值:

I have tried enhance contrast and then tresholding:

Mat tmp1 = imread("C:\\framesRoi\\311.bmp",0);
stretchContrast(tmp1);
threshold(tmp1,tmp1,75,255,THRESH_BINARY);

其中拉伸对比度impl:

where stretch contrast impl:

int minValue = 255, maxValue = 0;
const int l = sourceImg.cols * sourceImg.rows * sourceImg.channels();
if(sourceImg.isContinuous())
{
    uchar* ptr = sourceImg.ptr<uchar>(0);
    for(int i = 0; i < l; ++i)
    {
        if(ptr[i] < minValue)
        {
            minValue = ptr[i];
        }
        if(ptr[i] > maxValue)
        {
            maxValue = ptr[i];
        }
    }
}
cout<<"min: "<<minValue<<";"<<"max value: "<<maxValue<<endl;

const int  magicThreshold = 10;
if(sourceImg.isContinuous())
{
    uchar* ptr = sourceImg.ptr<uchar>(0);
    for(int i = 0; i < l; ++i)
    {
        ptr[i] = 255 * (ptr[i]-minValue)/(maxValue - minValue);
    }
}

但这种方法失败了。有许多错误检测并未检测到所有缺陷:

But this approach failed. There are many false detections and not all defects are detected:

这是包含测试帧的zip: https:// dl。 dropboxusercontent.com/u/47015140/testFrames.rar

Here is zip with test frames: https://dl.dropboxusercontent.com/u/47015140/testFrames.rar

推荐答案

尝试使用群集按灰度级对图像进行聚类方法,如kmeans。下面我直接在图像上使用了kmeans而没有任何灰度级变换(使用3个簇给了我更好的结果)。您应该能够通过使用评论中列出的方法对预处理的图像进行聚类来改善结果。

Try clustering the image by gray level using a clustering method such as kmeans. Below I've used kmeans directly on the images without any gray level transformations (using 3 clusters gave me better results). You should be able to improve results by clustering a preprocessed image using methods outlined in the comments.


由于kmeans的随机性,群集的形​​状可能会略有不同。

Shape of the clusters may slightly vary due to the randomness of kmeans.

现在,如果您采用连接的组件聚类图像并计算这些区域的平均灰度级,缺陷的平均值应低于其他区域。

Now if you take connected components of the clustered image and calculate the average gray level of those regions, the defects should have a lower average than the other regions.

我在Matlab中进行了聚类。

I did clustering part in Matlab.

im = imread('r2SOV.png');%Uy1Fq r2SOV
gr = im;
size = size(gr);

% perform closing using a 5x5 circular structuring element
sel = strel('disk', 2, 4);
mcl = imclose(gr, sel);
% cluster gray levels using kmeans: using 3 clusters
x = double(mcl(:));
idx = kmeans(x, 3);
cl = reshape(idx, size);

figure, imshow(label2rgb(cl))

这篇关于低对比度图像分割的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆