<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Zugriff über Canvas-&amp;gt;Pixels zu langsam - warum? alternativen Zugriff auf Pixel?]]></title><description><![CDATA[<p>Hallo.</p>
<p>Ich versuche in einem bitmap mit</p>
<p>bmp-&gt;Canvas-&gt;Pixels[x,y]</p>
<p>auf die einzelnen Pixel des Bildes zuzugreifen um sie dann einzeln zu manipulieren. (Schwellwertbildung -&gt; Binärisierung)</p>
<p>Das ganze dauert aber bei einem Bild mit etwas 600*500 Pixel fast 3 sec. Definitiv zu langsam. Woran kann das liegen? Gibt es eine andere Möglichkeit pixel direkt anzusteuern? ich der Hilfe habe ich nichts gefunden.</p>
<p>Vielen Dank<br />
Jan</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/119678/zugriff-über-canvas-gt-pixels-zu-langsam-warum-alternativen-zugriff-auf-pixel</link><generator>RSS for Node</generator><lastBuildDate>Sat, 25 Jul 2026 20:13:24 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/119678.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 04 Sep 2005 15:34:20 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Zugriff über Canvas-&amp;gt;Pixels zu langsam - warum? alternativen Zugriff auf Pixel? on Sun, 04 Sep 2005 15:34:20 GMT]]></title><description><![CDATA[<p>Hallo.</p>
<p>Ich versuche in einem bitmap mit</p>
<p>bmp-&gt;Canvas-&gt;Pixels[x,y]</p>
<p>auf die einzelnen Pixel des Bildes zuzugreifen um sie dann einzeln zu manipulieren. (Schwellwertbildung -&gt; Binärisierung)</p>
<p>Das ganze dauert aber bei einem Bild mit etwas 600*500 Pixel fast 3 sec. Definitiv zu langsam. Woran kann das liegen? Gibt es eine andere Möglichkeit pixel direkt anzusteuern? ich der Hilfe habe ich nichts gefunden.</p>
<p>Vielen Dank<br />
Jan</p>
]]></description><link>https://www.c-plusplus.net/forum/post/864677</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/864677</guid><dc:creator><![CDATA[talshiar]]></dc:creator><pubDate>Sun, 04 Sep 2005 15:34:20 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriff über Canvas-&amp;gt;Pixels zu langsam - warum? alternativen Zugriff auf Pixel? on Sun, 04 Sep 2005 16:05:54 GMT]]></title><description><![CDATA[<p>TBitmap::ScanLine ermöglicht den zeilenweisen Zugriff auf die Pixel. Ist um einiges schneller als über Canvas-&gt;Pixels[][].</p>
]]></description><link>https://www.c-plusplus.net/forum/post/864691</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/864691</guid><dc:creator><![CDATA[Killing me softly]]></dc:creator><pubDate>Sun, 04 Sep 2005 16:05:54 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriff über Canvas-&amp;gt;Pixels zu langsam - warum? alternativen Zugriff auf Pixel? on Sun, 04 Sep 2005 16:14:07 GMT]]></title><description><![CDATA[<p>so weit ich weiss aber nur zum lesen- oder?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/864696</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/864696</guid><dc:creator><![CDATA[talshiar]]></dc:creator><pubDate>Sun, 04 Sep 2005 16:14:07 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriff über Canvas-&amp;gt;Pixels zu langsam - warum? alternativen Zugriff auf Pixel? on Sun, 04 Sep 2005 16:44:37 GMT]]></title><description><![CDATA[<p>Die Eigenschaft ScanLine ist readonly, aber über ScanLine kannst du schreibend auf die Pixel zugreifen (siehe Beispiel in der Hilfe).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/864713</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/864713</guid><dc:creator><![CDATA[Killing me softly]]></dc:creator><pubDate>Sun, 04 Sep 2005 16:44:37 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriff über Canvas-&amp;gt;Pixels zu langsam - warum? alternativen Zugriff auf Pixel? on Sun, 04 Sep 2005 17:10:11 GMT]]></title><description><![CDATA[<p>ich habe das so eingebaut mit scanline.</p>
<p><div class="plugin-markdown"><input type="checkbox" id="checkbox64550" checked="true" /><label for="checkbox64550">ist genau wie in der hilfe, die rückgabe von scanline.</label></div></p>
<p>rot = GetRValue(ptr[x]);</p>
<p><div class="plugin-markdown"><input type="checkbox" id="checkbox64551" checked="true" /><label for="checkbox64551">für das gesamte bild nur 0...</label></div></p>
]]></description><link>https://www.c-plusplus.net/forum/post/864746</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/864746</guid><dc:creator><![CDATA[talshiar]]></dc:creator><pubDate>Sun, 04 Sep 2005 17:10:11 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriff über Canvas-&amp;gt;Pixels zu langsam - warum? alternativen Zugriff auf Pixel? on Sun, 04 Sep 2005 17:46:01 GMT]]></title><description><![CDATA[<p>hellsehen koennen wir noch nicht; zeig mal deinen gesamten code.</p>
<p>der zugriff ueber <strong>Canvas-&gt;Pixels[x][y]</strong> ist deshalb so langsam, da <strong>Pixels</strong> ein Property von Canvas ist und ueber eine Get- &amp; Set-Funktion beschrieben bzw. gelesen wird. damit hast du bei jedem pixel einen zusaetzlichen funktionsaufruf. dazu kommt noch der array-zugriff (2d-array). zuerst auf x und im anschluss auf y. durch die ganzen zusätzlichen funktionen sinkt natürlich die geschwindigkeit enorm und <strong>Pixels</strong> sollte daher nie verwendet werden sondern <strong>ScanLine</strong>.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/864780</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/864780</guid><dc:creator><![CDATA[Sunday]]></dc:creator><pubDate>Sun, 04 Sep 2005 17:46:01 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriff über Canvas-&amp;gt;Pixels zu langsam - warum? alternativen Zugriff auf Pixel? on Tue, 06 Sep 2005 18:08:46 GMT]]></title><description><![CDATA[<p>so - jetzt habe ich die sache mit scanline am laufen. aber toll ist die geschwindigkeit immernoch nicht. was kann man das noch machen? bmp ist das Bitmap und die Bilder sind nicht sonderlich gross - das muss schneller gehen.</p>
<pre><code class="language-cpp">void binaerisiere()
{
    byte *ptr;
    for(int y=0; y&lt;bmp-&gt;Height; y++)
    {
    	ptr = (byte *) bmp-&gt;ScanLine[y];

    	for (int x=0; x&lt;bmp-&gt;Width; x++)
    	{
           	if (ptr[x] &gt;= StrToInt(Form1-&gt;Schwellenwert_edit-&gt;Text))
                ptr[x]= 230;
            else
                ptr[x]= 0;
          }
    }
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/866481</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/866481</guid><dc:creator><![CDATA[talshiar]]></dc:creator><pubDate>Tue, 06 Sep 2005 18:08:46 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriff über Canvas-&amp;gt;Pixels zu langsam - warum? alternativen Zugriff auf Pixel? on Tue, 06 Sep 2005 18:25:52 GMT]]></title><description><![CDATA[<p>Du könntest die Feldmatirx kopieren und über diesse die Manipulation dürchführen .<br />
Das beste währe aber sicherlich den Speicher ausfindigzumachen und dort die Manipulation vorzunehmen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/866507</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/866507</guid><dc:creator><![CDATA[Tuol]]></dc:creator><pubDate>Tue, 06 Sep 2005 18:25:52 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriff über Canvas-&amp;gt;Pixels zu langsam - warum? alternativen Zugriff auf Pixel? on Tue, 06 Sep 2005 18:36:42 GMT]]></title><description><![CDATA[<p>was genau ist denn die Feldmatrix?</p>
<p>wie würde ich denn Speicherbereich rankommen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/866517</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/866517</guid><dc:creator><![CDATA[talshiar]]></dc:creator><pubDate>Tue, 06 Sep 2005 18:36:42 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriff über Canvas-&amp;gt;Pixels zu langsam - warum? alternativen Zugriff auf Pixel? on Tue, 06 Sep 2005 20:01:01 GMT]]></title><description><![CDATA[<p>Wenn es um Performance geht haben Sachen wie <em>StrToInt(Form1-&gt;Schwellenwert_edit-&gt;Text))</em> auf jeden Fall nichts in den Schleifen verloren, auch wenn das hier wohl nicht <strong>die</strong> Bremse ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/866578</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/866578</guid><dc:creator><![CDATA[Jansen]]></dc:creator><pubDate>Tue, 06 Sep 2005 20:01:01 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriff über Canvas-&amp;gt;Pixels zu langsam - warum? alternativen Zugriff auf Pixel? on Tue, 06 Sep 2005 20:03:30 GMT]]></title><description><![CDATA[<p>ja - ist schon klar. ich hatte da zwischendurch auch schon feste werte drin - das hat keinen unterschied gemacht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/866581</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/866581</guid><dc:creator><![CDATA[talshiar]]></dc:creator><pubDate>Tue, 06 Sep 2005 20:03:30 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriff über Canvas-&amp;gt;Pixels zu langsam - warum? alternativen Zugriff auf Pixel? on Wed, 07 Sep 2005 08:39:24 GMT]]></title><description><![CDATA[<p>talshiar schrieb:</p>
<blockquote>
<pre><code class="language-cpp">void binaerisiere()
{
    byte *ptr;
    for(int y=0; y&lt;bmp-&gt;Height; y++)
    {
    	ptr = (byte *) bmp-&gt;ScanLine[y];

    	for (int x=0; x&lt;bmp-&gt;Width; x++)
    	{
           	if (ptr[x] &gt;= StrToInt(Form1-&gt;Schwellenwert_edit-&gt;Text))
                ptr[x]= 230;
            else
                ptr[x]= 0;
          }
    }
}
</code></pre>
</blockquote>
<p>argh...</p>
<p>1. weg mit <strong>StrToInt()</strong><br />
-&gt; bei jedem Pixel rufst du die Funktion auf (dort wird in ner Schleife<br />
eine String in ne Zahl konvertiert -&gt; sehr schlecht, zumal die sich ja<br />
nicht aendert in der Schleife!)<br />
2. weg mit <strong>Form1-&gt;Schwellenwert_edit-&gt;Text</strong><br />
-&gt; bei jedem Pixel wird die Get-Funktion von <strong>Text</strong> aufgerufen<br />
-&gt; sehr schlecht!<br />
3. weg mit <strong>bmp-&gt;Width</strong> und <strong>bmp-&gt;Height</strong> da hier bei jedem Pixel<br />
die Get-Funktion fuer Width und Height aufgerufen werden und sich<br />
die Hoehe und Breite ja kaum aendert!</p>
<p>besser waere zum beispiel folgendes:</p>
<pre><code class="language-cpp">typedef unsigned char u_char;
typedef unsigned int  u_int;

void binaerisiere()
{
  u_char  Threshold = StrToInt(Form1-&gt;Schwellenwert_edit-&gt;Text);
  u_int   Height    = bmp-&gt;Height;
  u_int   Width     = bmp-&gt;Width;
  u_char *ptr;
  u_int   x, y;

  for (y = 0; y &lt; Height; ++y)
  {
    ptr = (u_char*) bmp-&gt;ScanLine[y];

    for (x = 0; x &lt; Width; ++x)
      *(ptr + x) = (*(ptr + x) &gt;= Threshold ? 230 : 0);
  }
}
</code></pre>
<p>besser lebst du sowieso, wenn du dir ne eigene bild-klasse baust und den ganzen vcl schnickschnack weglaesst. damit bist du dann auch unabhaengiger von der entwicklungsumgebnung.</p>
<p>ausserdem sollte die funktion das bild und den schwellwert uebergeben bekommen und diese nicht als globale variablen rumlungern!</p>
<p>duerfte auf jeden schneller sein als deine version, wenn nicht solltest du deine compiler-optionen ueberpruefne (release-modus).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/866789</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/866789</guid><dc:creator><![CDATA[Sunday]]></dc:creator><pubDate>Wed, 07 Sep 2005 08:39:24 GMT</pubDate></item></channel></rss>