<?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>noise Archives - Creatronix</title>
	<atom:link href="https://creatronix.de/tag/noise/feed/" rel="self" type="application/rss+xml" />
	<link>https://creatronix.de/tag/noise/</link>
	<description>My adventures in code &#38; business</description>
	<lastBuildDate>Tue, 23 Dec 2025 08:33:29 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Intro to OpenCV with Python</title>
		<link>https://creatronix.de/intro-to-opencv-with-python/</link>
		
		<dc:creator><![CDATA[Jörn]]></dc:creator>
		<pubDate>Mon, 23 Jul 2018 19:11:18 +0000</pubDate>
				<category><![CDATA[Data Science & SQL]]></category>
		<category><![CDATA[bgr]]></category>
		<category><![CDATA[blur]]></category>
		<category><![CDATA[gaussian]]></category>
		<category><![CDATA[noise]]></category>
		<category><![CDATA[opencv]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[rgb]]></category>
		<category><![CDATA[smoothing]]></category>
		<guid isPermaLink="false">http://creatronix.de/?p=1593</guid>

					<description><![CDATA[<p>Installation To work with OpenCV from python, you need to install it first. We additionally install numpy and matplotlib as well pip install opencv-python numpy matplotlib Reading Images from file After we import cv2 we can directly work with images like so: import cv2 img = cv2.imread("doc_brown.png") For showing the image, it is recommended to&#8230;</p>
<p>The post <a href="https://creatronix.de/intro-to-opencv-with-python/">Intro to OpenCV with Python</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Installation</h2>
<p>To work with OpenCV from python, you need to install it first. We additionally install numpy and matplotlib as well</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-bash" data-lang="Bash"><code>pip install opencv-python numpy matplotlib</code></pre>
</div>
<h2>Reading Images from file</h2>
<p>After we import cv2 we can directly work with images like so:</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-python" data-lang="Python"><code>import cv2 
img = cv2.imread("doc_brown.png")</code></pre>
</div>
<p>For showing the image, it is recommended to use matplotlib</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-python" data-lang="Python"><code>import matplotlib.pyplot as plt 
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) 
plt.imshow(img) 
plt.show()</code></pre>
</div>
<p>OpenCV stores images internally in the BGR format &#8211; blue &#8211; green &#8211; red so we have to convert to RGB before displaying them.</p>
<h2><img fetchpriority="high" decoding="async" class="alignnone size-full wp-image-1748" src="https://creatronix.de/wp-content/uploads/2018/07/doc_brown.png" alt="" width="640" height="480" srcset="https://creatronix.de/wp-content/uploads/2018/07/doc_brown.png 640w, https://creatronix.de/wp-content/uploads/2018/07/doc_brown-300x225.png 300w" sizes="(max-width: 640px) 100vw, 640px" /></h2>
<h2>Image Shape</h2>
<p>We have now an image object which can already tell us more about the image itself:</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-python" data-lang="Python"><code>print(img.shape) 
(205, 236, 3)</code></pre>
</div>
<p>The tuple shows us the number of (rows, columns, channels)</p>
<h2>Manipulate brightness</h2>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-python" data-lang="Python"><code>import numpy as np 
brightness = np.zeros(img.shape, dtype="uint8") + 30 
img = cv2.add(img, brightness)</code></pre>
</div>
<p>Manipulating brightness works like this: you need a numpy array with the size of the image, add your brightness and add the brightness array to the original image.</p>
<h2><img decoding="async" class="alignnone size-full wp-image-1749" src="https://creatronix.de/wp-content/uploads/2018/07/bright_doc_30.png" alt="" width="640" height="480" srcset="https://creatronix.de/wp-content/uploads/2018/07/bright_doc_30.png 640w, https://creatronix.de/wp-content/uploads/2018/07/bright_doc_30-300x225.png 300w" sizes="(max-width: 640px) 100vw, 640px" /></h2>
<h2>Adding noise</h2>
<p>Adding noise works the same way, but instead of adding a fixed value to every pixel you add normal distributed values.</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-python" data-lang="Python"><code>noise = np.random.randint(0, 100, size=img.shape, dtype="uint8") 
img = cv2.add(img, noise)</code></pre>
</div>
<p><img decoding="async" class="alignnone size-full wp-image-1811" src="https://creatronix.de/wp-content/uploads/2018/07/noisy_doc.png" alt="" width="640" height="480" srcset="https://creatronix.de/wp-content/uploads/2018/07/noisy_doc.png 640w, https://creatronix.de/wp-content/uploads/2018/07/noisy_doc-300x225.png 300w" sizes="(max-width: 640px) 100vw, 640px" /></p>
<h2>Smoothing</h2>
<p>Smoothing is reducing the noise of an image by adding a Gaussian blur:</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-python" data-lang="Python"><code>img = cv2.GaussianBlur(img, ksize=(31, 31), sigmaX=5)</code></pre>
</div>
<h2><img decoding="async" class="alignnone size-full wp-image-1812" src="https://creatronix.de/wp-content/uploads/2018/07/smooth_doc.png" alt="" width="640" height="480" srcset="https://creatronix.de/wp-content/uploads/2018/07/smooth_doc.png 640w, https://creatronix.de/wp-content/uploads/2018/07/smooth_doc-300x225.png 300w" sizes="(max-width: 640px) 100vw, 640px" /></h2>
<h2>Gray-scale conversion</h2>
<p>Last but not least we can convert an image to a gray scale. Beware that for showing / storing the image you need to add the flag cmap=&#8221;gray&#8221;</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-python" data-lang="Python"><code>img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 
plt.imshow(img, cmap='gray')</code></pre>
</div>
<p><img decoding="async" class="alignnone size-full wp-image-1815" src="https://creatronix.de/wp-content/uploads/2018/07/gray_doc.png" alt="" width="640" height="480" srcset="https://creatronix.de/wp-content/uploads/2018/07/gray_doc.png 640w, https://creatronix.de/wp-content/uploads/2018/07/gray_doc-300x225.png 300w" sizes="(max-width: 640px) 100vw, 640px" /></p>
<p>Have fun fiddling around with OpenCV!</p>
<h2>Github Repo</h2>
<p><a href="https://github.com/jboegeholz/introduction_to_opencv">https://github.com/jboegeholz/introduction_to_opencv</a></p>
<p>The post <a href="https://creatronix.de/intro-to-opencv-with-python/">Intro to OpenCV with Python</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
