Image Processing - Absolute sum of the differences employing a weighted kernel

1 次查看(过去 30 天)
Dear all,
I hope you can help. I am trying to replicate an alghoritm (for target detection) found in a research paper:
Unfortunately, I am stuck with an equation (see Eq. 20 and 21 in the link above), and I would grately appreciate your help.
I have an image, let's call it I (I=5x5).
I performed a Top-hat transform and now I need to apply a 'Local Difference Criterion'.
I created four direction vectors centered at I(i,j), where i and j are the coordinates of the central pixel. The four vectors are defined as:
L1=[I(i-2,j-2),I(i-1,j-1),I(i+1,j+1),I(i+2,j+2)];
L2=[I(i,j-2),I(i,j-1),I(i,j+1),I(i,j+2)];
L3=[I(i+2,j-2),I(i+1,j-1),I(i-1,j+1),I(i-2,j+2)];
L4=[I(i-2,j),I(i-1,j),I(i+1,j),I(i+2,j)];
Now, I need to calculate the sum of the differences in gray values between I(i+x,j+y) and I(i,j) as follows:
where Wx,y is the weighted kernel to describe the absolute difference between I(i+x,j+y) and I(i,j), and is equal to:
Would anyone be able to help me with writing a code to accomplish the above?
Thanks a lot in advance
  3 个评论
Simone A.
Simone A. 2023-5-1
Hi Matt, thanks for getting back to me. That's another reason why I found it difficult to solve it. I don't understand the notation on the actual paper linked above. Did you see the actual paper? Was it clear for you?
Image Analyst
Image Analyst 2023-5-1
编辑:Image Analyst 2023-5-1
An image of 5x5 is too small for this. Let's hope you made a mistake when you said "I have an image, let's call it I (I=5x5)". I've attached a manual filtering demo. You can build in the weights into it.

请先登录,再进行评论。

采纳的回答

Matt J
Matt J 2023-5-1
编辑:Matt J 2023-5-1
There are problems with the mathematical formulation, as noted in the comments above. However, for the general task of computing shift-invariant weighted differences, I would set it up like the following:
L(1).deltaX=[-2 -1 1 2]
L(1).deltaY=[-2 -1 1 2]
L(1).weight=rand(1,4);
L(2).deltaX=[0 0 0 0]
L(2).deltaY=[-2 -1 1 2]
L(2).weight=rand(1,4);
...
clear d
for i=numel(L):-1:1
tmp=0;
for j=1:4
x=L(i).deltaX(j); y=L(i).deltaY(j); wxy=L(i).weight(j);
tmp=tmp+wxy*abs(circshift(I,[x,y])-I);
end
d(:,:,i)=tmp;
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Mathematics and Optimization 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by