Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There's a few issues with that line of code: </p> <ul> <li><p>If your image is RGB (e.g., loaded from colour Jpeg or something), you'll have to add 3 layers of noise; e.g., use </p> <pre><code>rand([size(originalimage) 3]) </code></pre></li> <li><p><code>255*rand()</code> generates double-valued numbers, whereas your image will probably be of type <code>uint8</code> or so (check with <code>class(originalimage)</code>). To fix, use <code>randi</code> for instance:</p> <pre><code>noisyimage = randi(255, [size(originalimage) 3], class(originalimage)); </code></pre></li> <li><p>you add noise of maximum magnitude 255 to <em>all</em> pixels. This might overflow many of your pixels (that is, get assigned values higher than 255). To avoid, use something like </p> <pre><code>noisyimage = min(255, originalimage + randi(...) ); </code></pre></li> <li><p>The noise direction is only <em>positive</em>. True noise also sometimes brings <em>down</em> the values of the pixels. So, use something like </p> <pre><code>noisyimage = max(0, min(255, originalimage + randi(...)-127 ); </code></pre></li> <li><p>the maximum amplitude of 255 is actually <strong>way</strong> too big; you'll likely destroy your whole image and only get noise. Try a few different amplitudes, <code>A</code>, like so: </p> <pre><code>noisyimage = max(0, min(255, originalimage + randi(A, ...)-round(A/2) ); </code></pre></li> <li><p>The uniform distribution which <code>randi</code> uses is not a really good source of noise; you'd want some other distribution. Use the normal distribution: </p> <pre><code>uint8(A*randn(...)-round(A/2)) </code></pre> <p>or gamma: </p> <pre><code>uint8(A*randg(...)-round(A/2)) </code></pre> <p>etc.</p></li> </ul> <p>Now, that should get you started :) </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload