How can i make a 2d convolution filter to process an image

4 views (last 30 days)
My question is basically how can i implement a 3x3 2d convolution filter to process an image without using the matlab comands (filter2, conv2, etc). The structure of the filter is this
m1 m2 m3 m4 m5 m6 m7 m8 m9
but m1=m9, m2=m8, m3=m7, m4=m6
Mathematically speaking, the final coefficients of the 2d convolution filter would be:
m1Im(x-1,y-1) m2Im(x-1,y) m3Im(x-1,y+1) m4Im(x,y-1) m5Im(x,y) m6Im(x,y+1) m7Im(x+1,y-1) m8Im(x+1,y) m9Im(x+1,y+1)
Im(x,y) is the input image which its going to be processed
How can i implement this theory into matlab to create the convolution filter without using the predefined matlab commands?

Answers (1)

Image Analyst
Image Analyst on 21 Mar 2014
There's been a few of these questions lately. It's not trivial but it's not that hard either. It's the kind of thing where you could easily do it yourself with 4 nested for loops if you think about what the starting and stopping indexes should be. If you just try, you'll get it. Honestly, it's not that hard if you think about it.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!