<?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>TOOLBOX INTERACTION DESIGN &#187; Bilder</title>
	<atom:link href="http://ifdblog.org/toolbox/?cat=48&#038;feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://ifdblog.org/toolbox</link>
	<description>Interactiondesign Toolbox der Fachhochschule Magdeburg-Stendal</description>
	<lastBuildDate>Mon, 02 Jul 2012 16:50:35 +0000</lastBuildDate>
	<language>de-DE</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.1</generator>
		<item>
		<title>Processing Ws Teil 3 Pixeldaten verarbeiten und Arrays</title>
		<link>http://ifdblog.org/toolbox/?p=609</link>
		<comments>http://ifdblog.org/toolbox/?p=609#comments</comments>
		<pubDate>Tue, 22 Jun 2010 09:32:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Arrays]]></category>
		<category><![CDATA[Bilder]]></category>
		<category><![CDATA[PROCESSING]]></category>

		<guid isPermaLink="false">http://ifdblog.org/toolbox/?p=609</guid>
		<description><![CDATA[Bild- und Pixeloperationen Bilder können in mit loadImage() geladen und im PImage Objekt weiter verarbeitet werden. Neben dem einfachen Darstellen des Bildes kann man auch Pixel um Pixel verändern, ähnlich einem Photoshopfilter. Dieses Bild von Manfred Pecki besteht aus verschiedenen Grauwerten. Ich will das Bild in ein reines schwarz/weiß Bild verwandeln. Um zu entscheiden, ob [...]]]></description>
			<content:encoded><![CDATA[<p>Bild- und Pixeloperationen<br />
Bilder können in mit loadImage() geladen und im PImage Objekt weiter verarbeitet werden. Neben dem einfachen Darstellen des Bildes kann man auch Pixel um Pixel verändern, ähnlich einem Photoshopfilter.<br />
<a href="http://ifdblog.org/toolbox/wp-content/uploads/2010/06/manfred-pecki.png" rel="shadowbox[sbpost-609];player=img;"><img src="http://ifdblog.org/toolbox/wp-content/uploads/2010/06/manfred-pecki.png" alt="" title="manfred-pecki" width="176" height="247" class="alignnone size-full wp-image-610" /></a></p>
<p>Dieses Bild von Manfred Pecki besteht aus verschiedenen Grauwerten. Ich will das Bild in ein reines schwarz/weiß Bild verwandeln. Um zu entscheiden, ob ein Pixel in weiß umgewandelt werden soll, analysiere ich seine Grauwert. Liegt es innerhalb eines bestimmten Grenzwertes (myThreshold), wird es weiß, ansonsten schwarz (Farbwert: 255).</p>
<p>Dieser Grenzwert ist in diesem Beispiel dynamisch an die X-Position des Mauszeigers gekoppelt und gibt einen Wert zwischen 0 und 255 aus<br />
float myThreshold = (float)mouseX / width * 255;</p>
<p>Nachdem das Bild geladen ist<br />
myImage = loadImage(&#8220;data/manfred-pecki.png&#8221;);<br />
und als Hintergrundbild wiedergegeben ist<br />
background(myImage);</p>
<p>kann ich mit loadPixels() jedes einzelne Pixel meiner Anwendung in einem Array zur Verfügung stellen, verändern und dieses veränderte Pixel mit updatePixels() neu auf die Screen rendern.</p>
<p>Das passiert alles in der draw() Methode in einer for-Schleife, die genau so lang ist wie das Bild Pixel hat. Diese Länge erhalte ich in einem Array mit pixels.length. Bei welchem Pixel ich mich gerade befinde sagt mir der Zähler myPixelPosition.</p>
<p>In jedem Schleifendurchlauf wird die Funbktion setPixelFromBitmap() aufgerufen, die entscheidet ob ein Pixel weiß oder schwarz werden soll.<br />
Ist die Schleife abgearbeitet, wird das Ergebnis mit updatePixels(); auf die Screen gerendert.</p>
<p>Hier wird auch deutlich, das die Länge und Breite des Bildes für die Verarbeitung keine Rolle spielt, sondern das Bild einfach eine lineare Aneinanderreihung von einzelnen Pixeln ist.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">PImage myImage<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">int</span> myPixelPosition<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  size<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">176</span>,<span style="color: #cc66cc;">247</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//Screnn in der Größe des importieren Bildes</span>
  frameRate<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #666666; font-style: italic;">// myImage = loadImage(&quot;http://ifdblog.org/ba-om2010/data_processingblog&quot;);</span>
  myImage <span style="color: #339933;">=</span> loadImage<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;data/manfred-pecki.png&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  background<span style="color: #009900;">&#40;</span>myImage<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">void</span> draw<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">/* lädt die komplette Screen in den Array pixels[] von myImage */</span>
  loadPixels<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">/* den &quot;Schwellwert&quot; festlegen
  *  Operation ergibt einen Wert von 0 - 255
  */</span>
  <span style="color: #000066; font-weight: bold;">float</span> myThreshold <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">float</span><span style="color: #009900;">&#41;</span>mouseX <span style="color: #339933;">/</span> width <span style="color: #339933;">*</span> <span style="color: #cc66cc;">255</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> pixels.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    setPixelFromBitmap<span style="color: #009900;">&#40;</span>myThreshold<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">/*
    * Inkrement von myPixelPosition und mit dem *Modulo* wird
    * garantierrt, dass der Array in seinen Grenzen bleibt
    */</span>
    myPixelPosition<span style="color: #339933;">++;</span>
    myPixelPosition<span style="color: #339933;">%=</span> pixels.<span style="color: #006633;">length</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #666666; font-style: italic;">/* alle Pixels darstellen */</span>
  updatePixels<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">void</span> setPixelFromBitmap<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">float</span> theThreshold<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">/*
  * das aktuelle Pixel abfragen
  * myPixePosition ist global definiert und kann deshalb überall verwendet werden
  */</span>
  <span style="color: #000066; font-weight: bold;">int</span> myImagePixel <span style="color: #339933;">=</span> myImage.<span style="color: #006633;">pixels</span><span style="color: #009900;">&#91;</span>myPixelPosition<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">/*
  * Abfrage, ob aktuelle Pixel größer oder kleiner ist als der Schwellwert...
  * entsprechend wird der Farbwert invertiert
  */</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>brightness<span style="color: #009900;">&#40;</span>myImagePixel<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> theThreshold<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    pixels<span style="color: #009900;">&#91;</span>myPixelPosition<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> color<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
    pixels<span style="color: #009900;">&#91;</span>myPixelPosition<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> color<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Modulo<br />
Der Modulo gibt mir den Rest einer Division zurück.<br />
5 Modulo 2 = 1<br />
5 % 2 = 1<br />
Damit kann ich einen Zähler erstellen, der nie über einen Bestimmten Wert wächst und einen Array out of Bounds Fehler produziert, also einen Arrayindex abfragt der größer wäre als der Arry tatsächlich ist:<br />
myPixelPosition%= pixels.length;<br />
wo_befinde_ich_mich_im_array %= gesamtlänge_des_arrays</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> myArray<span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">int</span> myArrayPosition<span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  size<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">320</span>, <span style="color: #cc66cc;">240</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  frameRate<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  rectMode<span style="color: #009900;">&#40;</span>CENTER<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  myArray <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #cc66cc;">40</span>, <span style="color: #cc66cc;">80</span>, <span style="color: #cc66cc;">120</span>, <span style="color: #cc66cc;">160</span>, <span style="color: #cc66cc;">200</span>, <span style="color: #cc66cc;">240</span>, <span style="color: #cc66cc;">280</span>  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">void</span> draw<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  background<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  myArrayPosition<span style="color: #339933;">++;</span>
  myArrayPosition <span style="color: #339933;">%=</span> myArray.<span style="color: #006633;">length</span><span style="color: #339933;">;</span>
  println<span style="color: #009900;">&#40;</span>myArrayPosition<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  rect<span style="color: #009900;">&#40;</span>myArray<span style="color: #009900;">&#91;</span>myArrayPosition<span style="color: #009900;">&#93;</span>, height <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">40</span>, height <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://ifdblog.org/toolbox/?feed=rss2&#038;p=609</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Camera draws the Screen</title>
		<link>http://ifdblog.org/toolbox/?p=360</link>
		<comments>http://ifdblog.org/toolbox/?p=360#comments</comments>
		<pubDate>Sat, 12 Jun 2010 09:59:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Bilder]]></category>
		<category><![CDATA[PROCESSING]]></category>

		<guid isPermaLink="false">http://ifdblog.org/toolbox/?p=360</guid>
		<description><![CDATA[This is on how to use the live camera picture to draw the screen. /** * Getting Started with Capture. * * Reading and displaying an image from an attached Capture device. */ &#160; //importiert die processing video library import processing.video.*; &#160; //erzeugt eine instanz der Klasse Capture mit dem namen cam Capture cam; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>This is on how to use the live camera picture to draw the screen.</p>
<p><a href="http://ifdblog.org/toolbox/wp-content/uploads/2010/06/Camera.png" rel="shadowbox[sbpost-360];player=img;"><img class="alignnone size-full wp-image-414" title="Camera" src="http://ifdblog.org/toolbox/wp-content/uploads/2010/06/Camera.png" alt="" width="480" height="350" /></a></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * Getting Started with Capture.
 *
 * Reading and displaying an image from an attached Capture device.
 */</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">//importiert die processing video library</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">processing.video.*</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//erzeugt eine instanz der Klasse Capture mit dem namen cam</span>
Capture cam<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  size<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">640</span>, <span style="color: #cc66cc;">480</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// initialisiert das objekt indem es den construktor aufruft</span>
  cam <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Capture<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>, <span style="color: #cc66cc;">320</span>, <span style="color: #cc66cc;">240</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//gibt eine liste der vorhandenen Kameras aus, wenn man nicht die</span>
  <span style="color: #666666; font-style: italic;">//Standart Kamera beutzen möchte...</span>
  <span style="color: #666666; font-style: italic;">//String[] devices = Capture.list();</span>
  <span style="color: #666666; font-style: italic;">//println(devices);</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// ...ändert man den Arrayplatz von devices[] zu dem gewünschtem</span>
  <span style="color: #666666; font-style: italic;">//cam = new Capture(this, width, height, devices[0]);</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// öffnet die einstellungen für die initialisierte kamera</span>
  <span style="color: #666666; font-style: italic;">//camera.settings();</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">void</span> draw<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">//wenn ein neues bild von der Kamera vorhanden ist...</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>cam.<span style="color: #006633;">available</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">//Kamerabild auslesen</span>
    cam.<span style="color: #006633;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//den tint der gezeichneten bilder auf 60% alphawert setzen</span>
    tint<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span>, <span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//zeichnet das Kamerabild and er mouseposition mit halber originalgröße</span>
    image<span style="color: #009900;">&#40;</span>cam, mouseX<span style="color: #339933;">-</span>cam.<span style="color: #006633;">width</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">4</span>, mouseY<span style="color: #339933;">-</span>cam.<span style="color: #006633;">height</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">4</span>,cam.<span style="color: #006633;">width</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">2</span>, cam.<span style="color: #006633;">height</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://ifdblog.org/toolbox/?feed=rss2&#038;p=360</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
