图像处理以八度音调大小的气泡 [英] Image processing to size bubbles in octave

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

问题描述

您好我想知道是否有人可以提供任何关于在下面的图像中调整水面(不是它下面的气泡)的可能方法的指示。如果可能的话,我想使用开源软件(考虑到图像是矩阵,我的思维倾向于八度)。我绝对没有图像处理的背景,所以欢迎任何想法。显然,作为一个起点,我知道原始图像中每个像素的大小(此图像是压缩版本),因此以像素为单位计算半径将是完美的。



< a href =http://i46.tinypic.com/volbhx.jpg =nofollow noreferrer>气泡图片http://i46.tinypic.com/volbhx.jpg



根据@mmgp的想法进行编辑



所以试着让问题更直接我有使用Opencv的开源库来了解@mmgp的想法。我之前从未使用过它(也没有用C或C ++直接编程,但它看起来好像可以满足我的需求,虽然它看起来好像有一个陡峭的学习曲线我的经验告诉我那些提供最强大功能的解决方案需要花时间学习。所以这就是我到目前为止所做的事情(没有图像处理的背景我不确定我使用的功能是否理想,但我认为它可能会促进进一步的思考)。我已将图像转换为灰度,使用二进制阈值,然后对圆圈应用Hough变换。我在每个阶段生成的图像和我使用的代码一样。很清楚的是跟踪器对于动态调整参数非常有用。然而,我还没有足够的娴熟能够在我的代码中实现它们(任何指针都会很棒,特别是关于Hough变换,其中有一些参数可以调整)。



那么什么你觉得吗?我还有什么其他的功能?尝试?很明显,我的尝试远没有@mmgp那么好,但这可能只是调整参数。



以下是照片:
灰度(完整性) ):
灰度图像http://i49.tinypic.com/avsj69.jpg
二进制阈值:
灰度图像http://i45.tinypic.com/ 16061e9.jpg
圆形图像:
灰度图像http:// i47.tinypic.com/2dtrfpd.jpg



以下是代码:

  #includeopencv2 / highgui / highgui.hpp
#includeopencv2 / imgproc / imgproc.hpp
#include< iostream>
#include< stdio.h>使用命名空间cv

;

/ ** @function main * /
int main(int argc,char ** argv)
{
Mat src,src_gray,src_bw;

///阅读图片
src = imread(argv [1],1);

if(!src.data)
{return -1; }

///将其转换为灰色
cvtColor(src,src_gray,CV_BGR2GRAY);
imwrite(Gray_Image.jpg,src_gray);

///将图像阈值设为二进制
阈值(src_gray,src_bw,140,255,CV_THRESH_BINARY);
imwrite(Binary_Image.jpg,src_bw);

vector< Vec3f>界;

///应用Hough变换找到圆圈
HoughCircles(src_bw,圆圈,CV_HOUGH_GRADIENT,5,src_bw.rows / 2,5,10,0,0);

///绘制检测到的圆圈
for(size_t i = 0; i< circles.size(); i ++)
{
Point center(cvRound) (circles [i] [0]),cvRound(circles [i] [1]));
int radius = cvRound(circles [i] [2]);
// circle center
circle(src,center,3,Scalar(0,255,0),-1,8,0);
//圈子轮廓
圈(src,center,radius,Scalar(0,0,255),3,8,0);
}

///显示结果
namedWindow(Hough Circle Transform Demo,0);
namedWindow(Gray,0);
namedWindow(Binary Threshold,0);
imshow(Hough Circle Transform Demo,src);
imshow(Gray,src_gray);
imshow(Binary Threshold,src_bw);
imwrite(Circles_Image.jpg,src);
waitKey(0);
返回0;
}


解决方案

另一种可能考虑的途径是模板匹配



您只需要创建典型气泡的模板图像。



这可能有助于识别由Hough变换识别的误报。 / p>

您需要使用不同大小的模板图像来检测不同大小的气泡。



此外,如果你有在气泡出现之前的水的图片,你可以减去这个以找到有气泡的图像区域。


Hi I am wondering whether anybody can offer any pointers on a potential approach to sizing the bubbles at the water surface (not those below it) in the following image. I would like to use an open source software if possible (my mind is leaning towards octave given that an image is a matrix). I have absolutely no background in image processing so any ideas are welcome. Obviously as a starting point I know the size of each pixel in the raw image (this image is a compressed version) so calculating a radius in pixels would be perfect.

Bubble image http://i46.tinypic.com/volbhx.jpg

Edit based upon the thoughts of @mmgp

So to try and make the question more direct I have taken onboard the thoughts of @mmgp using the open source libraries of Opencv. I have never used this before (nor indeed programmed directly in C or C++ however it looks as though it could fulfil my needs and although it looks as though it may have a steep learning curve my experience tells me those solutions that offer the most power often require time spent learning. So here is what I have done so far (with no background in image processing I am not sure if the functions I have used are ideal but I thought it might promote further thought). I have converted the image to grayscale, used a binary threshold and then applied a Hough Transform for circles. The images I generate at each stage are below as well as the code I have used. What is clear is that trackerbars are very useful for tweaking the parameters on the fly. I am however not yet adept enough to implement them in my code (any pointers would be great especially regarding the Hough transform where there are a few parameters to tweak).

So what do you think? What other function(s) might I try? Clearly my attempt is nowhere near as good as @mmgp but that may just be a matter of tweaking parameters.

Here are the photos: Grayscale(for completeness): Grayscale image http://i49.tinypic.com/avsj69.jpg Binary threshold: Grayscale image http://i45.tinypic.com/16061e9.jpg Circle image: Grayscale image http://i47.tinypic.com/2dtrfpd.jpg

Here is the code:

 #include "opencv2/highgui/highgui.hpp"
 #include "opencv2/imgproc/imgproc.hpp"
 #include <iostream>
 #include <stdio.h>

 using namespace cv;

 /** @function main */
 int main(int argc, char** argv)
 {
 Mat src, src_gray, src_bw;

 /// Read the image
 src = imread( argv[1], 1 );

 if( !src.data )
 { return -1; }

 /// Convert it to gray
 cvtColor( src, src_gray, CV_BGR2GRAY );
 imwrite( "Gray_Image.jpg", src_gray );

 /// Threshold the image to make binary
 threshold(src_gray, src_bw, 140, 255, CV_THRESH_BINARY);
 imwrite( "Binary_Image.jpg", src_bw );

 vector<Vec3f> circles;

 /// Apply the Hough Transform to find the circles
 HoughCircles( src_bw, circles, CV_HOUGH_GRADIENT, 5, src_bw.rows/2, 5, 10, 0, 0 );

 /// Draw the circles detected
 for( size_t i = 0; i < circles.size(); i++ )
 {
 Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));
 int radius = cvRound(circles[i][2]);
 // circle center
 circle( src, center, 3, Scalar(0,255,0), -1, 8, 0 );
 // circle outline
 circle( src, center, radius, Scalar(0,0,255), 3, 8, 0 );
 }

 /// Show your results
 namedWindow( "Hough Circle Transform Demo", 0 );
 namedWindow( "Gray", 0 );
 namedWindow( "Binary Threshold", 0 );
 imshow( "Hough Circle Transform Demo", src );
 imshow( "Gray", src_gray );
 imshow( "Binary Threshold", src_bw );
 imwrite( "Circles_Image.jpg", src );
 waitKey(0);
 return 0;
 }

解决方案

Another possible path to consider would be Template matching

you just need to create a template image of a typical bubble.

This might be useful for identifying false positives identified by the Hough transform.

You will need to use template images of varying sizes for detecting different size bubbles.

Also, if you have a picture of the water from before the bubbles appeared, you can subtract this to find areas of the image that have bubbles.

这篇关于图像处理以八度音调大小的气泡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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