Asked by Mary Jon
on 18 Sep 2013

(v(i,j))^(k+1)= (1-ω)(v(i,j))^(k)-ω[(W1(i,j)(v(i+1,j))^(k)+ W2(i,j)(v(i-1,j))^(k+1)+ W3(i,j)(v(i,j+1)^(k)+ W4(i,j)(v(i,j-1))^(k+1)(/(W i,j)]

v matrix k iteration W may by matrix (have i &j) w constant

*No products are associated with this question.*

Answer by John Petersen
on 18 Sep 2013

The trick is to update v(i-1,j) and v(i,j-1) without updating v(i+1,j) and v(i,j+1) before going on the v(i,j). After that do:

v(i,j)= (1-ω)*v(i,j) - ω*[(W1(i,j)*v(i+1,j) + W2(i,j)*v(i-1,j) + W3(i,j)*v(i,j+1) + W4(i,j)*v(i,j-1))/W(i,j)]

Image Analyst
on 18 Sep 2013

convolution, conv2(), and imfilter() do this "trick" inherently and efficiently. With your code, as you move over to the next j, your v(i,j) will now be the new v(i, j-1) and will be affected. So it will have some kind of recursive/hysteresis effect or trailing blur or something that's not right. imfilter() and conv2() do not suffer from this. If she insists on using two nested for loops (a much less efficient approach especially for larger windows) then she'll have to at least assign the result (right hand side of the equation) to a new output variable, like vout(i,j), not the original input variable.

conv2() and imfilter are more efficient because they only need to read in and discard a few of the pixels on the edge, not the whole array. For example with a 7x7 window, you have 49 elements/pixels in the window but as you slide over one pixel you only need to read in 7 new pixels, not all 49.

Answer by Image Analyst
on 18 Sep 2013

Edited by Image Analyst
on 18 Sep 2013

Looks like unsharp masking, so you can do this

kernel = [0, W1, 0; W3, 0, W4; 0, W2, 0]; filtered = conv2(vk, kernel, 'same'); vk = (1-omega)*vk + filtered./W;

Show 5 older comments

Image Analyst
on 19 Sep 2013

What are the values of W1, W2, etc.? They're probably arrays, what are they?

Image Analyst
on 20 Sep 2013

Opportunities for recent engineering grads.

## 0 Comments