<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with increment() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=increment%28%29</link>
      <pubDate>Sun, 08 Aug 2021 20:13:02 +0000</pubDate>
         <description>Tagged with increment() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedincrement%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>Use 2D array to find coincidences of words</title>
      <link>https://forum.processing.org/two/discussion/27481/use-2d-array-to-find-coincidences-of-words</link>
      <pubDate>Thu, 29 Mar 2018 18:41:07 +0000</pubDate>
      <dc:creator>Rayle</dc:creator>
      <guid isPermaLink="false">27481@/two/discussions</guid>
      <description><![CDATA[<p>I am triying to discover how many times words from a list appear together in the sentences of a given text. The first thing I did was to find the sentences with a particular word (law in the example below), make an array with them, and count the times the other words appear with an <code>IntDict</code>.</p>

<p>This is the code</p>

<pre><code>StringList results;
IntDict coincidence;

void setup() {

  String [] text = loadStrings("text.txt");
  String onePhrase = join(text, " ").toLowerCase();
  String [] phrases = splitTokens(onePhrase, ".?!");
  String search = "\\blaw.?\\b";
  String [] wordList = loadStrings("wordList.txt");

for (int i = 0; i&lt;phrases.length; i ++) {
      String [] matching = match(phrases[i], search);
      if (matching != null) {
        results.append(phrases[i]); 
    }
  }

   String [] resultsArray = results.array();

   String joinResults = join(resultsArray, " ");
   String [] splitResults = splitTokens(joinResults, " -,.:;¿?¿!/_");

    for(int i = 0; i &lt; splitResults.length; i++) {
    for (String searching : wordList) {
      if (splitResults[i].equals(searching)){
      coincidence.increment(splitResults[i]);
    }
   }
  }
</code></pre>

<p>But if I want to count how many times each word of the list appears together with the other ones, I need to remake the process a lot of times.</p>

<p>I tried with <code>Array[][]</code> but it doesn't work. Now I am stuck with the problem and I don't know how to proceed. I would appreciate any idea.</p>

<pre><code>StringList list;
String [] search;

void setup() {

  String [] text = loadStrings("text.txt");
  String onePhrase = join(text, " ").toLowerCase();
  String [] phrases = splitTokens(onePhrase, ".?!");

  Table table = loadTable("listOfWords.csv", "header");

  for (int i = 0; i &lt;table.getRowCount(); i ++) {
   TableRow row = table.getRow(i);
   list.append(row.getString("Word"));
   search = list.array();
  }

  for (int i = 0; i &lt; phrases.length; i ++) {
    for (int j = 0; j &lt; search.length; j ++) {
      String [][] matching = matchAll(phrases[i], search[j]);

       printArray(matching);
    }
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>how to repeat number in array.</title>
      <link>https://forum.processing.org/two/discussion/16731/how-to-repeat-number-in-array</link>
      <pubDate>Sat, 21 May 2016 08:02:15 +0000</pubDate>
      <dc:creator>allsun</dc:creator>
      <guid isPermaLink="false">16731@/two/discussions</guid>
      <description><![CDATA[<p>I don't know how to find repeat number simply, like find mode in a array.(using processing )</p>
]]></description>
   </item>
   <item>
      <title>Pixel sorting: Arranging all the pixels from an image in a color wheel. Is it possible?</title>
      <link>https://forum.processing.org/two/discussion/15164/pixel-sorting-arranging-all-the-pixels-from-an-image-in-a-color-wheel-is-it-possible</link>
      <pubDate>Sat, 27 Feb 2016 21:50:02 +0000</pubDate>
      <dc:creator>rmbrown</dc:creator>
      <guid isPermaLink="false">15164@/two/discussions</guid>
      <description><![CDATA[<p>I am new to Processing, and I have done quite a lot of searching, but I dont seem to be getting anywhere. My objective is to take all the colours from an image, and arrange them by hue in a colour wheel. I presume the result will represent a pie chart more than an actual spectrum, but that's ok.</p>

<p>I am a designer not a programmer, so integers and arrays are a little alien to me. I have however got code from the GENERATIVE DESIGN book which I thought might work:
<a href="http://www.generative-gestaltung.de/P_1_1_2_01" target="_blank" rel="nofollow">http://www.generative-gestaltung.de/P_1_1_2_01</a> for a colour spectrum, 
<a href="http://www.generative-gestaltung.de/P_1_2_2_01" target="_blank" rel="nofollow">http://www.generative-gestaltung.de/P_1_2_2_01</a> which loads the colour pixels from the image, however does not really arrange them, and uses the mouse x, y coords to tile the colours. It does seem to group similar hues together, which is perfect.</p>

<p>I think what I need is some kind of a cross between these two projects. So firstly, is something like this possible?
And if so, am I looking in the right place?
Thanks in advance.
R</p>
]]></description>
   </item>
   <item>
      <title>Getting the dominant color of an image</title>
      <link>https://forum.processing.org/two/discussion/14393/getting-the-dominant-color-of-an-image</link>
      <pubDate>Mon, 11 Jan 2016 14:04:58 +0000</pubDate>
      <dc:creator>Se_Ga</dc:creator>
      <guid isPermaLink="false">14393@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>im trying to get the most dominant color of an image (perfect case: getting the 5 dominant colors sorted by most used).</p>

<p>Is there a way to make that in processing? I tried already a code i found but with that im only getting the average color:</p>

<pre><code>color extractColorFromImage(PImage img) {
    img.loadPixels();
    int r = 0, g = 0, b = 0;
    for (int i=0; i&lt;img.pixels.length; i++) {
        color c = img.pixels[i];
        r += c&gt;&gt;16&amp;0xFF;
        g += c&gt;&gt;8&amp;0xFF;
        b += c&amp;0xFF;
    }
    r /= img.pixels.length;
    g /= img.pixels.length;
    b /= img.pixels.length;

    return color(r, g, b);
}
</code></pre>

<p>So its not really that what i need.</p>

<p>I already read that i could do it with HSV, k-means and so on.... and any way to do it in processing?</p>

<p>Example: Here i want to get the color red as the dominant color, with the example above im getting a dark orange.</p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/469/74T1OWM68NIM.png" alt="capture1" title="capture1" /></p>
]]></description>
   </item>
   <item>
      <title>Splitting strings into individual words then comparing with words from different strings</title>
      <link>https://forum.processing.org/two/discussion/13882/splitting-strings-into-individual-words-then-comparing-with-words-from-different-strings</link>
      <pubDate>Thu, 10 Dec 2015 19:34:03 +0000</pubDate>
      <dc:creator>rumlac</dc:creator>
      <guid isPermaLink="false">13882@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>I am trying to do the following:</p>

<p>Load in a single sentence (unknown number of words but not many). (This part doesn't need solved, I already have sentences coming in).</p>

<p>Split into individual words,
Save words,</p>

<p>load next string</p>

<p>Split string into words, check if any of the words are already saved (and if so, add 1 to the quantity of that specific word). If word isn't already saved, save it.</p>

<p>Repeat with x number of sentences.</p>

<p>Essentially the idea is to build up an arrayList(?) of words, and then display the top 4 most frequently used words in the sketch window.</p>

<p>Note. I've set up a bit of code that removes all common words such as "the" "and""to" etc.</p>

<p>Here is the relevant piece of code I have been experimenting with (Only addressing part of the issue at the moment) :</p>

<pre><code>    String[] splitWords = split(sentence, " "); //split sentence into individual words

    int numberOfWords2 = splitWords.length; //count number of words in sentence

    for (int p=0; p&lt;=splitWords.length; p++) { //add words to array list
      myWords.append(splitWords[p]);
    }

    sentenceCount = sentenceCount +1; //count number of sentences
    println(sentenceCount);

    numberOfWords = numberOfWords+numberOfWords2; //total number of words
</code></pre>

<p>The main issue I am having is adding the words to the arrayList AFTER the existing words, rather than replacing them.</p>

<p>I am also unsure of the best way to keep a count of how many times each word has appeared across all sentences.</p>

<p>Thanks!</p>
]]></description>
   </item>
   <item>
      <title>How to find the frequency of occurrence of a number or a string in an array</title>
      <link>https://forum.processing.org/two/discussion/11275/how-to-find-the-frequency-of-occurrence-of-a-number-or-a-string-in-an-array</link>
      <pubDate>Thu, 11 Jun 2015 22:44:57 +0000</pubDate>
      <dc:creator>yousufalin</dc:creator>
      <guid isPermaLink="false">11275@/two/discussions</guid>
      <description><![CDATA[<p>Hello everyone,</p>

<pre><code>    int [] number= {4,5,6,3,5,3,5,6,6,8};
    String [] animal= {cat,dog,rat,cat,cat,dog,dog,dog,cat,rat};
    void setup(){
    size(800,800);
    smooth();

    }

    void draw(){
    background(0);

    }
</code></pre>

<p>I would like to know how can I write a code that will find me the repeated occurrence of each of the number/string in the array.</p>

<p>my aim is to list the numbers and strings as follows</p>

<p>Number 3 = 2
Number 4 = 1
Number 5 = 3
Number 6 = 3
Number 8 = 1</p>

<p>cat = 4
Dog = 4
rat =2</p>

<p>Any help will be greatly appreciated.</p>

<p>Many thanks in advance :)</p>
]]></description>
   </item>
   </channel>
</rss>