<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Kristou Says &#187; OpenCV</title>
	<atom:link href="http://mehrez.kristou.org/category/computer/opencv/feed/" rel="self" type="application/rss+xml" />
	<link>http://mehrez.kristou.org</link>
	<description>I share my experience</description>
	<lastBuildDate>Wed, 29 Jun 2011 19:25:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Color interpolation in OpenCV</title>
		<link>http://mehrez.kristou.org/color-interpolation-in-opencv/</link>
		<comments>http://mehrez.kristou.org/color-interpolation-in-opencv/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 04:23:07 +0000</pubDate>
		<dc:creator>Kristou Mehrez</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[OpenCV]]></category>

		<guid isPermaLink="false">http://mehrez.kristou.org/?p=1456</guid>
		<description><![CDATA[I could not find in Internet a function which can return a RGB color value between two colors So I had to do it myself. I hope it will be useful for someone. 

<code>CvScalar interpolate(CvScalar c1, CvScalar c2, double value){
    if( value <= 0.0 ){ return c1; }
    if( value >= 1.0 ){ return c2; }
    int red	= cvRound((1.0 - value) * c1.val[2] + value * c2.val[2]);
    int green	= cvRound((1.0 - value) * c1.val[1] + value * c2.val[1]);
    int blue	= cvRound((1.0 - value) * c1.val[0] + value * c2.val[0]);
    return CV_RGB(red, green, blue);
}</code>]]></description>
			<content:encoded><![CDATA[<p>I could not find in Internet a function which can return a RGB color value between two colors So I had to do it myself. I hope it will be useful for someone. </p>
<p><code>CvScalar interpolate(CvScalar c1, CvScalar c2, double value){<br />
    if( value <= 0.0 ){ return c1; }<br />
    if( value >= 1.0 ){ return c2; }<br />
    int red	= cvRound((1.0 - value) * c1.val[2] + value * c2.val[2]);<br />
    int green	= cvRound((1.0 - value) * c1.val[1] + value * c2.val[1]);<br />
    int blue	= cvRound((1.0 - value) * c1.val[0] + value * c2.val[0]);<br />
    return CV_RGB(red, green, blue);<br />
}</code></p>
]]></content:encoded>
			<wfw:commentRss>http://mehrez.kristou.org/color-interpolation-in-opencv/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Edge orientation</title>
		<link>http://mehrez.kristou.org/edge-orientation/</link>
		<comments>http://mehrez.kristou.org/edge-orientation/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 10:31:26 +0000</pubDate>
		<dc:creator>Kristou Mehrez</dc:creator>
				<category><![CDATA[OpenCV]]></category>

		<guid isPermaLink="false">http://www.kristou.com/?p=1258</guid>
		<description><![CDATA[This is a sample code for getting the edges orientation in an image. 
 
CvMat *filter_x=cvCreateMat(1,3,CV_32FC1); filter_x->data.fl[0]=-1; 
filter_x->data.fl[1]=0; filter_x->data.fl[2]=1; 
CvMat *filter_y=cvCreateMat(3,1,CV_32FC1); filter_y->data.fl[0]=-1; 
filter_y->data.fl[1]=0; filter_y->data.fl[2]=1; 
IplImage *img_src=cvLoadImage("name",0); 
IplImage *img_diff_x=cvCreateImage(cvGetSize(img_src),IPL_DEPTH_32F,1); 
IplImage *img_diff_y=cvCreateImage(cvGetSize(img_src),IPL_DEPTH_32F,1); 
IplImage *img_32f=cvCreateImage(cvGetSize(img_src),IPL_DEPTH_32F,1); 
cvConvert(img_src,img_32f); 
cvFilter2D(img_32f,filter_x,img_diff_x); 
cvFilter2D(img_32f,filter_y,img_diff_y); 
IplImage *magnitude=cvCreateImage(cvGetSize(img_src),IPL_DEPTH_32F,1); 
IplImage *orientation=cvCreateImage(cvGetSize(img_src),IPL_DEPTH_32F,1); 
cvCartToPolar(img_diff_x, img_diff_y, magnitude, orientation, 1)]]></description>
			<content:encoded><![CDATA[<p>This is a sample code for getting the edges orientation in an image.</p>
<p><code>CvMat *filter_x=cvCreateMat(1,3,CV_32FC1); filter_x->data.fl[0]=-1;<br />
filter_x->data.fl[1]=0; filter_x->data.fl[2]=1;<br />
CvMat *filter_y=cvCreateMat(3,1,CV_32FC1); filter_y->data.fl[0]=-1;<br />
filter_y->data.fl[1]=0; filter_y->data.fl[2]=1;<br />
IplImage *img_src=cvLoadImage("name",0);<br />
IplImage *img_diff_x=cvCreateImage(cvGetSize(img_src),IPL_DEPTH_32F,1);<br />
IplImage *img_diff_y=cvCreateImage(cvGetSize(img_src),IPL_DEPTH_32F,1);<br />
IplImage *img_32f=cvCreateImage(cvGetSize(img_src),IPL_DEPTH_32F,1);<br />
cvConvert(img_src,img_32f);<br />
cvFilter2D(img_32f,filter_x,img_diff_x);<br />
cvFilter2D(img_32f,filter_y,img_diff_y);<br />
IplImage *magnitude=cvCreateImage(cvGetSize(img_src),IPL_DEPTH_32F,1);<br />
IplImage *orientation=cvCreateImage(cvGetSize(img_src),IPL_DEPTH_32F,1);<br />
cvCartToPolar(img_diff_x, img_diff_y, magnitude, orientation, 1);</code></p>
]]></content:encoded>
			<wfw:commentRss>http://mehrez.kristou.org/edge-orientation/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Convert Polar image into Cartesian</title>
		<link>http://mehrez.kristou.org/convert-polar-image-into-cartesian/</link>
		<comments>http://mehrez.kristou.org/convert-polar-image-into-cartesian/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 16:27:54 +0000</pubDate>
		<dc:creator>Kristou Mehrez</dc:creator>
				<category><![CDATA[OpenCV]]></category>

		<guid isPermaLink="false">http://www.kristou.com/?p=1185</guid>
		<description><![CDATA[This a simple implementation of Polar to Cartesian transformation applied to the image case. It is useful to unroll an omni image to convert it to panoramic image. imgPol = cvCreateImage(cvSize(2*CV_PI*RadiusMax,RadiusMax-RadiusMin),IPL_DEPTH_8U,1); cvSet(imgPol,CV_WHITE,NULL); int x0,y0; double Radius; double Angle; for(int x=1; x < imgPol->width; x++) { for(int y=1; y < imgPol->height; y++) { Radius = RadiusMin [...]]]></description>
			<content:encoded><![CDATA[<p>This a simple implementation of Polar to Cartesian transformation applied to the image case. It is useful to unroll an omni image to convert it to panoramic image.</p>
<pre class="brush:cpp">
imgPol = cvCreateImage(cvSize(2*CV_PI*RadiusMax,RadiusMax-RadiusMin),IPL_DEPTH_8U,1);
cvSet(imgPol,CV_WHITE,NULL);
int x0,y0;
double Radius;
double Angle;
for(int x=1; x < imgPol->width; x++)
{
	for(int y=1; y < imgPol->height; y++)
	{
		Radius = RadiusMin + y;
		Angle = 2 * CV_PI * x / imgPol->width;
		x0 = cvRound(CenterX + Radius * cos(Angle));
		y0 = cvRound(CenterY + Radius * sin(Angle));

		cvSet2D(imgPol, y, x, cvGet2D(imgBase,y0,x0));
	}
}

cvSaveImage("imgPol.bmp",imgPol);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://mehrez.kristou.org/convert-polar-image-into-cartesian/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Closing gaps in image</title>
		<link>http://mehrez.kristou.org/closing-gaps-in-image/</link>
		<comments>http://mehrez.kristou.org/closing-gaps-in-image/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 14:42:45 +0000</pubDate>
		<dc:creator>Kristou Mehrez</dc:creator>
				<category><![CDATA[OpenCV]]></category>

		<guid isPermaLink="false">http://www.kristou.com/?p=1124</guid>
		<description><![CDATA[This an example on how to use morphological operator in OpenCV to close gaps. int main(int argc, char* argv[]) { IplImage *image; IplImage *dilated_image; IplImage *eroded_image; image = cvLoadImage ("triangle.jpg"); dilated_image = cvCloneImage (image); eroded_image = cvCloneImage (image); cvNamedWindow ("Original", 1); cvNamedWindow ("Dilated", 1); cvNamedWindow ("Eroded", 1); cvShowImage ("Original", image); cvDilate (image, dilated_image, 0, 7); [...]]]></description>
			<content:encoded><![CDATA[<p>This an example on how to use morphological operator in OpenCV to close gaps.</p>
<pre class="brush:cpp">
<p>int main(int argc, char* argv[])<br />
{<br />
IplImage *image;<br />
IplImage *dilated_image;<br />
IplImage *eroded_image;<br />
image = cvLoadImage ("triangle.jpg");</p>
<p>dilated_image = cvCloneImage (image);<br />
eroded_image = cvCloneImage (image);</p>
<p>cvNamedWindow ("Original", 1);<br />
cvNamedWindow ("Dilated", 1);<br />
cvNamedWindow ("Eroded", 1);</p>
<p>cvShowImage ("Original", image);</p>
<p>cvDilate (image, dilated_image, 0, 7);<br />
cvShowImage ("Dilated", dilated_image);</p>
<p>cvErode (dilated_image, eroded_image, 0, 6);<br />
cvShowImage ("Eroded", eroded_image);</p>
<p>cvWaitKey ();</p>
<p>cvReleaseImage (&#038;image);<br />
cvDestroyWindow ("Original");<br />
cvReleaseImage (&#038;dilated_image);<br />
cvDestroyWindow ("Dilated");<br />
cvReleaseImage (&#038;eroded_image);<br />
cvDestroyWindow ("Eroded");</p>
<p>return 0;<br />
}
</pre</p>
]]></content:encoded>
			<wfw:commentRss>http://mehrez.kristou.org/closing-gaps-in-image/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Circle detection</title>
		<link>http://mehrez.kristou.org/circle-detection/</link>
		<comments>http://mehrez.kristou.org/circle-detection/#comments</comments>
		<pubDate>Mon, 16 Nov 2009 12:54:06 +0000</pubDate>
		<dc:creator>Kristou Mehrez</dc:creator>
				<category><![CDATA[OpenCV]]></category>

		<guid isPermaLink="false">http://www.kristou.com/?p=1111</guid>
		<description><![CDATA[This a source code for sircle detection. void findCircles( IplImage* img, CvMemStorage* storage ){ CvSeq* circles; IplImage* cpy = cvCreateImage(cvGetSize(img),8,1); int i; float* circ; cvCvtColor(img,cpy,CV_RGB2GRAY); circles = cvHoughCircles(cpy,storage,CV_HOUGH_GRADIENT,2,cpy->height/4,200,100); for(i=0;i < circles->total;i++){ CvSeq circ=(float*)cvGetSeqElem(circles,i); cvCircle(img,cvPoint(cvRound(circ[0]),cvRound(circ[1])),cvRound(circ[2]),CV_RGB(255,255,255),1,8,0); } cvReleaseImage(&#038;cpy); }]]></description>
			<content:encoded><![CDATA[<p>This a source code for sircle detection.</p>
<pre class="brush:cpp">
void findCircles( IplImage* img, CvMemStorage* storage ){
CvSeq* circles;
IplImage* cpy = cvCreateImage(cvGetSize(img),8,1);
int i;
float* circ;
cvCvtColor(img,cpy,CV_RGB2GRAY);
circles =
cvHoughCircles(cpy,storage,CV_HOUGH_GRADIENT,2,cpy->height/4,200,100);
for(i=0;i < circles->total;i++){
CvSeq
circ=(float*)cvGetSeqElem(circles,i);

cvCircle(img,cvPoint(cvRound(circ[0]),cvRound(circ[1])),cvRound(circ[2]),CV_RGB(255,255,255),1,8,0);
}
cvReleaseImage(&#038;cpy);

}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://mehrez.kristou.org/circle-detection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

