Sum two matrices shifted by a non integer number?

조회 수: 7 (최근 30일)
MementoMori
MementoMori 2023년 3월 26일
편집: Matt J 2023년 3월 26일
Suppose we have two matrices A and B, and I want to sum them shifted by a non-integer number of pixels. How can I do it?
For example for a 0.5 shift. We can enlarge them by a factor of 2, sum them shifted by 1 pixel and reduce it by a factor 2.
But this way can be very computational expensive, in particular for a low pixel shift.

채택된 답변

Matt J
Matt J 2023년 3월 26일
편집: Matt J 2023년 3월 26일
Because of the linearity of interpolation, you should not interpolate each matrix. You should sum the matrices first, then interpolate the result, e.g,
C=imtranslate(A+B,[0.5,0]);
which will cut down the computation by half.

추가 답변 (1개)

John D'Errico
John D'Errico 2023년 3월 26일
There is no magic, whereby you can do things that take computational time, and do them instantly.
What you want to do is implicitly interpolate the images, at sub-pixel levels. You can use interp2 to interpolate one array at a shift of some fractional amount. Then add the results. But no matter what, you will need to perform an interpolation.
  댓글 수: 1
MementoMori
MementoMori 2023년 3월 26일
Yes I know, I was wondering if there was a faster way than my idea or interpolation

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

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by