title: How to update image values by identifying unique locations in MATLAB?
body: <p>I have a image matrix named <code>final_img</code>. I have image location matrix with rows and columns is given below</p>
  
  <pre><code>a =
  
       1     1
       1     2
       2     1
       2     2
       3     1
       3     2
       1     1
       2     2
  </code></pre>
  
  <p>and values of this locations are</p>
  
  <pre><code>b =
  
       1
       2
       3
       4
       5
       6
       7
       8
  </code></pre>
  
  <p>In above given locations, some are repeating eg: location <code>[1 1]</code> .  I can identify unique locations by using following code</p>
  
  <pre><code>[uniquerow, ~, rowidx] = unique(a, 'rows'); 
  noccurrences = accumarray(rowidx, 1);
  </code></pre>
  
  <p>I need to update unique image locations by summing image location values. Eg: location <code>[1 1]</code> is repeating <code>twice</code> and corresponding value in <code>b</code> are <code>1</code> and <code>7</code>. So </p>
  
  <p><code>final_img(1,1)</code> should be <code>1+7=8;</code></p>
  
  <p>How can I implement this algorithm in MATLAB without using for loop?</p>