在此图像中找到几乎圆形的亮像素带 [英] Find a nearly circular band of bright pixels in this image

查看:126
本文介绍了在此图像中找到几乎圆形的亮像素带的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我遇到的问题:我有一个如下图所示的图像。我想检测一下我用红线标记的圆形区域(特别是明亮的环)。

This is the problem I have: I have an image as shown below. I want to detect the circular region which I have marked with a red line for display here (that particular bright ring).

最初,这就是我现在所做的:(MATLAB)

Initially, this is what I do for now: (MATLAB)

binaryImage = imdilate(binaryImage,strel('disk',5)); 
binaryImage = imfill(binaryImage, 'holes'); % Fill holes.
binaryImage = bwareaopen(binaryImage, 20000); % Remove small blobs.
binaryImage = imerode(binaryImage,strel('disk',300));
out = binaryImage;
img_display = immultiply(binaryImage,rgb2gray(J1));
figure, imshow(img_display);

输出似乎在对象的一个​​部分上被剪切(对于不同的图像作为输入,而不是显示的那个以上)。我希望输出的方式是对称的(当它旋转时它并不总是一个完美的圆圈。)

The output seems to be cut on one of the parts of the object (for a different image as input, not the one displayed above). I want an output in such a way that it is symmetric (its not always a perfect circle, when it is rotated).

我想要尽快严格避免im2bw当我二进制化时,我失去了很多关于形状的信息。

I want to strictly avoid im2bw since as soon as I binarize, I lose a lot of information about the shape.

这就是我的想法:

我可以检测到图像的最外圆(几乎圆形)轮廓(以黄色显示)。从这里,我可以找到质心,也许找到一个半径为50%的圆(找到红色所示的区域)。但由于物体略微倾斜,因此不会完全对称。我该如何解决这个问题?

I can detect the outer most circular (almost circular) contour of the image (shown in yellow). From this, I can find out the centroid and maybe find a circle which has a radius of 50% (to locate the region shown in red). But this won't be exactly symmetric since the object is slightly tilted. How can I tackle this issue?

我附加了另一个图像,其中物体略微倾斜这里

I have attached another image where object is slightly tilted here

推荐答案

我会尝试搞乱'log'过滤器。您想要的区域本质上是二阶导数的低值(即斜率在下降的位置),您可以使用对数滤波器检测这些区域并找到负值。以下是您可以做的基本概要,然后根据您的需要进行调整。

I'd try messing around with the 'log' filter. The region you want is essentially low values of the 2nd order derivative (i.e. where the slope is decreasing), and you can detect these regions by using a log filter and finding negative values. Here's a very basic outline of what you can do, and then tweak it to your needs.

img = im2double(rgb2gray(imread('wheel.png')));
img = imresize(img, 0.25, 'bicubic');

filt_img = imfilter(img, fspecial('log',31,5));
bin_img = filt_img < 0;

subplot(2,2,1);
imshow(filt_img,[]);

% Get regionprops
rp = regionprops(bin_img,'EulerNumber','Eccentricity','Area','PixelIdxList','PixelList'); 
rp = rp([rp.EulerNumber] == 0 & [rp.Eccentricity] < 0.5 & [rp.Area] > 2000);

bin_img(:) = false;
bin_img(vertcat(rp.PixelIdxList)) = true;
subplot(2,2,2);
imshow(bin_img,[]);

bin_img(:) = false;
bin_img(rp(1).PixelIdxList) = true;
bin_img = imfill(bin_img,'holes');

img_new = img;
img_new(~bin_img) = 0;

subplot(2,2,3);
imshow(img_new,[]);

bin_img(:) = false;
bin_img(rp(2).PixelIdxList) = true;
bin_img = imfill(bin_img,'holes');

img_new = img;
img_new(~bin_img) = 0;

subplot(2,2,4);
imshow(img_new,[]);

输出:

这篇关于在此图像中找到几乎圆形的亮像素带的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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