Convolution from bottom right

Hi all
I want to do a convolution from the bottom right and not as usual from the top left. I think conv2 of Matlab only does from the top left.
How can I do a convolution in Matlab from the bottom right?
Thank you very much for the answers.

 采纳的回答

Image Analyst
Image Analyst 2014-5-13

1 个投票

After it's done it makes absolutely no difference. There is no need whatsoever to do what you're asking. Unless you're wanting to not flip the kernel. In that case use imfilter(), but it almost certainly starts at row #1 like conv2(), the only difference is it doesn't flip the kernel.

5 个评论

In my case it makes a difference. I'm referring to the paper "Digital Images Inpainting using Modified Convolution Based Method".
Page 7 of the paper:
"Modifying the diffusion kernel or the filter to zero weight at the bottom right corner instead of the center and making the convolution from the bottom right corner are sample but accurate and play an important role in the inpainting process ,from figure 4 and figure 5-b we noted that, this modification forbidden the need to iterate the convolution operation because the inpainted pixel produced from the above left neighborhoods pixels (known pixels) , now we don’t need to repeated blurring (convolution) because the goal of repetition achieved from the first averaging iteration."
It doesn't make sense to me. What he said is not precise enough to figure out what he did. For example, he did not give the kernel weights. His diagram is not illustrative of what gets multiplied by what and where the window moves to next. I stand by what I said: it doesn't make any difference where you start scanning your window from when you do a convolution. If he does something like changing the weights or size or orientation of the kernel, or the kernel is applied to already filtered output pixels as it moves along, then it's no longer a convolution - it's some custom non-linear filter. But because the explanation (perhaps purposely) left out a lot of details of the implementation, it's impossible to tell what it's really doing. I suggest you ask the author for clarification.
I think I found out what the trick is. The author mean with "making the convolution from the bottom right corner" that the bottom right pixel get replaced and not the center.
So if we have the image
1 2 3
4 5 6
7 8 9
We now put the kernel over this patch as with normal convolution but in a normal convolution the center 5 will be replaced. In our case now the 9 will be replaced.
How can this in Matlab be done? I.e. convolution but replacing not the middle but the bottom right pixel of the patch.
You'd just make a larger kernel with zeros:
1 2 3 0 0 0 0
4 5 6 0 0 0 0
7 8 9 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
or maybe
1 2 3 0 0
4 5 6 0 0
7 8 9 0 0
0 0 0 0 0
0 0 0 0 0
Seems to make sense, I will give it a try.

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by