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.

댓글 수: 1

Sara
Sara 2014년 5월 13일
what about flipping the matrix before the convolution?

댓글을 달려면 로그인하십시오.

 채택된 답변

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

Sepp
Sepp 2014년 5월 13일
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."
Image Analyst
Image Analyst 2014년 5월 13일
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.
Sepp
Sepp 2014년 5월 14일
편집: Sepp 2014년 5월 14일
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.
Image Analyst
Image Analyst 2014년 5월 14일
편집: Image Analyst 2014년 5월 14일
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
Sepp
Sepp 2014년 5월 14일
Seems to make sense, I will give it a try.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

질문:

2014년 5월 13일

댓글:

2014년 5월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by