Given a center, sum adjacent pixels

Hi, suppose I have a matrix A and I have a center (for example (10.3,14.6)). Now I want to calculate the value of the center in this way
value = w1*A(10,14) + w2*A(10,15) + w3*A(11,14) + w4*A(11,15)
w1, w2, w3, w4 are the values of the weigths that are proportional to the distance of the pixel from the center.
What is the most correct way to evaluate w1, w2, w3, w4? I want that the weigth of the pixel that is closer to the center higher and the weigth of the pixel that is farther to the center lower and so on.
My hyphotesis is something like this:
w1=0.7 * 0.4 ; w2=0.7*0.6; w3=0.3*0.4; w4= 0.3*0.6
Thanks

댓글 수: 6

Benjamin Thompson
Benjamin Thompson 2022년 10월 3일
Can you add more to your description with sample values you would like to see for w1, w2, w3, w4 as part of your example?
MementoMori
MementoMori 2022년 10월 3일
Hi, thanks for the answer I have added my hyphotesis and a description
dpb
dpb 2022년 10월 3일
Are you saying you want to solve for a set of weights that will produce the given value from the four or recompute a revised "center" by weight the four values?
MementoMori
MementoMori 2022년 10월 3일
편집: MementoMori 2022년 10월 3일
Hi, thanks for the answer.
No, I want to calculate a sort of value of the center, making a weighted sum of the pixels around the center. The weights have to be proportional to the distance of the pixel from the center.
dpb
dpb 2022년 10월 3일
NB the weights above sum to 2 which will double the value...and "proportional" how (linear, quadratic, exponential, ...) and by what measure of "distance"?
MementoMori
MementoMori 2022년 10월 3일
the sum of the weights is 1. 0.7*0.4 + 0.7*0.6 + 0.3*0.4 + 0.3*0.6 =1
I think linear proportional and I don't know for distance, what is the most suitable?

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

답변 (1개)

Matt J
Matt J 2022년 10월 3일
편집: Matt J 2022년 10월 3일

0 개 추천

Use interp2:
value=interp2(A,14.3,10.6)

카테고리

도움말 센터File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

질문:

2022년 10월 3일

편집:

2022년 10월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by