Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Let <strong>f</strong> be the original image, <strong>g</strong> be the filtered one, and <strong>h</strong> the filter applied to <strong>f</strong>, so that:</p> <pre><code>f * h = g </code></pre> <p>Passing that to the frequency domain:</p> <pre><code>F.H = G, so H = G/F </code></pre> <p>The problem is that inverting F is VERY sensitive to noise.</p> <p>How to implement that in MATLAB:</p> <pre><code>close all; f = imread('cameraman.tif'); [x,y] = size(f); figure,imshow(f); h = fspecial('motion', 20, 40); % abitrary filter just for testing the algorithm F = fft2(f); H = fft2(h,x,y); G = F.*H; g = ifft2(G); % the filtered image figure, imshow(g/max(g(:))); % Inverting the original image epsilon = 10^(-10); small_values = find(abs(F)&lt;epsilon); F(small_values) = epsilon; F_i = ones(x,y)./F; H_calculated = G.*F_i; h_calculated = ifft2(H_calculated); % remove really small values to try to infer the original size of h r = sum(h_calculated,1)&lt;epsilon; c = sum(h_calculated,2)&lt;epsilon; h_real = h_calculated(~r,~c); % Calculate error % redo the filtering with the found filter figure,g_comp = ifft2(fft2(f).*fft2(h_real,x,y)); imshow(g_comp/max(g_comp(:))); rmse = sqrt(mean(mean((double(g_comp) - double(g)).^2,2),1)) </code></pre> <p><strong>edit</strong>: Just to explain the epsilon part:</p> <p>It can be that some values in F are zero, or very close to zero. If we try to invert F with these small values, we would have problems with infinity. The easy way to solve that is to truncate every value in F that is smaller than an arbitrarily small limit, epsilon on the code.</p> <p>Mathematically, what was done is this:</p> <pre><code>For all F &lt; epsilon, F = epsilon </code></pre>
    singulars
    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.
    3. 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