Skip to content Skip to sidebar Skip to footer

Do I Have To Create A Whole New Array To Store Results From Convolution?

I was playing with my convolution algorithm in Python and I noticed that while sliding the filter along the original array and updating entries therein, the result came out quite m

Solution 1:

You should use a second array to store the result. Otherwise you are basing most of your calculations on pixels you have already changed instead of on the original pixels that were in the image. That's why your first example changes more than you expect.

Technically you can do it without a second array by using threads. You just need to have as many threads as you have pixels. Then each thread calculates one pixel and stores it back in the image. This will take even more memory than just using a second array, however, and you have to carefully synchronize things to avoid modifying pixels you still need for calculations. Also, it's going to be slower.

Post a Comment for "Do I Have To Create A Whole New Array To Store Results From Convolution?"