필터 지우기
필터 지우기

distance between an image and a sliding window

조회 수: 1 (최근 30일)
Julien Renoult
Julien Renoult 2017년 12월 1일
답변: Image Analyst 2017년 12월 2일
Hi ! I have an image I of size 300x300 pix, and a "filter" F of size 12x12 pix, and I would like to slide this patch everywhere on I and for each position, to extract the euclidean distance between F and the 12x12 local patch of I. Is there an efficient way to encode this ? In advance, Thanks !
  댓글 수: 2
Rik
Rik 2017년 12월 1일
Do you mean a convolution? If so, Matlab has a function to do that. I don't really understand what you mean with the distance between the sample and the filter. Could you provide a small example of how this should work?
Also, have a read here and here. It will greatly improve your chances of getting an answer.
Julien Renoult
Julien Renoult 2017년 12월 1일
Hi. Thanks for your comment. A kind of convolution but I do not want the product of the filter and the patch, but the euclidean distance. Currently I have this peace of code. My problem is that it is really time-consuming (I repeat this on thousands of images) and I thus would like to avoid these two "for" loops.
F = rand(12,12,4); % I did not mentioned it before but in fact I have 3D filters and images
I = rand(70,100,4);
sz = size(F,1);
[dx2,dy2,~]=size(I);
for y=1:dy2-sz
for x=1:dx2-sz
P = I(x:x+sz-1,y:y+sz-1,:);
R = F - P;
R = R.^2;
R = sum(sum(sum(R)));
J(x,y) = R;
end
end

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

답변 (1개)

Image Analyst
Image Analyst 2017년 12월 2일
Convolve I with F first using convn(). Then use immse().

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by