<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=404343&amp;view=findpost&amp;p=3614062</guid>
        <pubDate>Mon, 20 Jul 2015 18:22:21 +0000</pubDate>
        <title>Алгоритм Флойда-Стенберга</title>
        <link>https://forum.sources.ru/index.php?showtopic=404343&amp;view=findpost&amp;p=3614062</link>
        <description><![CDATA[hd44780: Заработало, результат хороший.<br><br><br>Спасибо всем откликнувшимся.]]></description>
        <author>hd44780</author>
        <category>Программирование графики</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=404343&amp;view=findpost&amp;p=3613719</guid>
        <pubDate>Sat, 18 Jul 2015 18:34:50 +0000</pubDate>
        <title>Алгоритм Флойда-Стенберга</title>
        <link>https://forum.sources.ru/index.php?showtopic=404343&amp;view=findpost&amp;p=3613719</link>
        <description><![CDATA[Victor Tsaregorodtsev: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=404343&view=findpost&p=3613654'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>x128 &#064; <time class="tag-quote__quoted-time" datetime="2015-07-18T07:44:41+00:00">18.07.15, 07:44</time></span><div class='quote '>Нужно учитывать переполнение при распределении ошибки, т.е. все значения &lt;0 и &gt;255 должны быть приведены к 0 и 255.</div></div><br>
И всё это отрезанное (вышедшее за диапазон) при желании можно прибавлять к нераспределённой ошибке и переносить в соседние пикселы.]]></description>
        <author>Victor Tsaregorodtsev</author>
        <category>Программирование графики</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=404343&amp;view=findpost&amp;p=3613707</guid>
        <pubDate>Sat, 18 Jul 2015 16:48:28 +0000</pubDate>
        <title>Алгоритм Флойда-Стенберга</title>
        <link>https://forum.sources.ru/index.php?showtopic=404343&amp;view=findpost&amp;p=3613707</link>
        <description><![CDATA[amk: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=404343&view=findpost&p=3613654'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>x128 &#064; <time class="tag-quote__quoted-time" datetime="2015-07-18T07:44:41+00:00">18.07.15, 07:44</time></span><div class='quote '>Нужно учитывать переполнение при распределении ошибки, т.е. все значения &lt;0 и &gt;255 должны быть приведены к 0 и 255.</div></div> Или надо вычисления вести в расширенном диапазоне. Хотя в обоих случаях иногда свои артефакты появляются.]]></description>
        <author>amk</author>
        <category>Программирование графики</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=404343&amp;view=findpost&amp;p=3613698</guid>
        <pubDate>Sat, 18 Jul 2015 15:18:45 +0000</pubDate>
        <title>Алгоритм Флойда-Стенберга</title>
        <link>https://forum.sources.ru/index.php?showtopic=404343&amp;view=findpost&amp;p=3613698</link>
        <description><![CDATA[hd44780: Да, спасибо большое, помогло. Блин, хрен поймёшь, как правильно реализовывать эти теоретические алгоритмы.<br>Погоняю ещё на других картинках, отпишусь.]]></description>
        <author>hd44780</author>
        <category>Программирование графики</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=404343&amp;view=findpost&amp;p=3613654</guid>
        <pubDate>Sat, 18 Jul 2015 07:44:41 +0000</pubDate>
        <title>Алгоритм Флойда-Стенберга</title>
        <link>https://forum.sources.ru/index.php?showtopic=404343&amp;view=findpost&amp;p=3613654</link>
        <description><![CDATA[x128: Нужно учитывать переполнение при распределении ошибки, т.е. все значения &lt;0 и &gt;255 должны быть приведены к 0 и 255.]]></description>
        <author>x128</author>
        <category>Программирование графики</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=404343&amp;view=findpost&amp;p=3613609</guid>
        <pubDate>Fri, 17 Jul 2015 18:09:13 +0000</pubDate>
        <title>Алгоритм Флойда-Стенберга</title>
        <link>https://forum.sources.ru/index.php?showtopic=404343&amp;view=findpost&amp;p=3613609</link>
        <description><![CDATA[hd44780: Привет всем.<br>
Реализовываю данный алгоритм на микроконтроллере, поэтому интересует голый алгоритм, без каких-либо библиотек, модулей, плагинов и родственных тому вещей.<br>
<br>
За основу взял вот это описание - <a class='tag-url' href='http://www.intuit.ru/studies/courses/993/163/lecture/4511?page=3' target='_blank'>http://www.intuit.ru/studies/courses/993/1...ure/4511?page=3</a><br>
Получилось вот такое:<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">&nbsp;&nbsp; &nbsp;// Читаем 1-ю строку картинки</div><div class="code_line">&nbsp;&nbsp; &nbsp;SSTF016B_ReadBuffer ( source_addr, pLine1, width );</div><div class="code_line">&nbsp;&nbsp; &nbsp;source_addr += width;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;// Читаем 2-ю строку картинки</div><div class="code_line">&nbsp;&nbsp; &nbsp;SSTF016B_ReadBuffer ( source_addr, pLine2, width );</div><div class="code_line">&nbsp;&nbsp; &nbsp;source_addr += width;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;for ( y = 0; y &#60; height; y ++ )</div><div class="code_line">&nbsp;&nbsp; &nbsp;{ // цикл по строкам изображения</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;for ( x = 0; x &#60; width; x ++ )</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{ // цикл по столбцам</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;oldpixel = pLine1 [ x ];</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ( oldpixel &#62; 150 )</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;newpixel = 255;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;quant_error &nbsp;= oldpixel - 255;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} // if</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;newpixel = 0;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;quant_error = oldpixel;</div><div class="code_line">// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;quant_error = 0;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} // else</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Запись полученного пикселя</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SSTF016B_WriteByte ( dest_addr ++, newpixel );</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Коррекция</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pLine1 [x+1] += ( ( 7 * quant_error) &#62;&#62; 4 ); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// 1 - я коррекция</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ( x &#62;= 1 )</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pLine2 [ x-1 ] += ( ( 3 * quant_error ) &#62;&#62; 4 ); &nbsp; &nbsp; // 2 - я коррекция</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pLine2 [ x ] += ( ( 5 * quant_error ) &#62;&#62; 4 ); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 3 - я коррекция</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pLine2 [ x + 1 ] += ( quant_error &#62;&#62; 4 ); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 4 - я коррекция</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;} // for</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// Подготовка к обработке след строки</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// Перенос 2-го буфера в первый</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;memcpy ( pLine1, pLine2, width );</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// Чтение следующей строки</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;SSTF016B_ReadBuffer ( source_addr, pLine2, width );</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;source_addr += width;</div><div class="code_line">&nbsp;&nbsp; &nbsp;} // for</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script><br>
<br>
Из-за ограниченности ресурсов контроллера в памяти единовременно держу только 2 строки изображения.<br>
Исходное изображение - серое, файл angel-grey658_665.bmp. Считывается он абсолютно нормально, проверено выводом на дисплей устройства.<br>
Результат - angel_out.bmp. То, что он перевернут вдоль вертикальной оси - не проблема, это следствие переворота его на компьютере, железка сохраняет его в перевёрнутом виде. Смущают чёрные пятна внизу и белое пятно слева.<br>
<br>
Если в ветке else сделать так:<br>
//            	quant_error = oldpixel;<br>
            	quant_error = 0;<br>
<br>
Такой вариант тоже встречается на просторах интернета.<br>
При этом получаем angel_out.bmp. Низ получился нормальный, но вот белые пятна слева увеличились. Почему - непонятно.<br>
<br>
Кто-то может помочь?<br>
<br>
bmp положил в архивах, т.к. форум блокирует .bmp :(<br>
Спасибо.<br>
<span class="b-attach" data-size="238295" data-hits="170" data-attach-id="45961" data-attach-post-id="3613609">
			<span class="b-attach__title"></span><a class='b-attach-link' href='https://forum.sources.ru/index.php?act=Attach&amp;type=post&amp;id=3613609&amp;attach_id=45961' title='Скачать файл' target='_blank'>angel_grey658_665.zip</a> (, : 170)
		</span><br>
<span class="b-attach" data-size="35075" data-hits="171" data-attach-id="45962" data-attach-post-id="3613609">
			<span class="b-attach__title"></span><a class='b-attach-link' href='https://forum.sources.ru/index.php?act=Attach&amp;type=post&amp;id=3613609&amp;attach_id=45962' title='Скачать файл' target='_blank'>angel_out.zip</a> (, : 171)
		</span><br>
<span class="b-attach" data-size="51318" data-hits="166" data-attach-id="45963" data-attach-post-id="3613609">
			<span class="b-attach__title"></span><a class='b-attach-link' href='https://forum.sources.ru/index.php?act=Attach&amp;type=post&amp;id=3613609&amp;attach_id=45963' title='Скачать файл' target='_blank'>angel_out_1.zip</a> (, : 166)
		</span>]]></description>
        <author>hd44780</author>
        <category>Программирование графики</category>
      </item>
	
      </channel>
      </rss>
	