Discontinuities in imgaussfilt3 near integer values of sigma
조회 수: 1 (최근 30일)
이전 댓글 표시
I've noticed some discontinuities in the way that imgaussfilt3 works when sigma nears (and passes) and integer value. This is readily reproducible, as shown below:
rng(1)
A=randn(100,100,100);
ind=find(A==max(A(:)));
X=linspace(.9,5.1,1000);
dist=0*X;
for i=1:1000
i
B=imgaussfilt3(A,X(i));
dist(i)=B(ind);
end
scatter(X,dist)
This gives the following plot, clearly showing issues at integer values. This is also visible if you increase the "resolution", that is something like X=linspace(2.98,3.02,1000) with the same loop, you readily see this issue.
What's happening here ? Why is this function not continuous as a function of inputted sigma ?
댓글 수: 0
채택된 답변
DGM
2021년 8월 10일
편집: DGM
2021년 8월 10일
This also happens for imgaussfilt() and others (e.g. using MIMT fkgen() and imfilter()). If you take a closer look, you'll notice it's not strictly integer-values that are the problem areas. It's integers and half-integers.
rng(1)
A=randn(100,100);
ind=find(A==max(A(:)));
X=linspace(.9,5.1,1000);
dist=0*X;
for i=1:1000
B=imgaussfilt(A,X(i));
dist(i)=B(ind);
end
plot(X,dist,'.')
grid on
These defects are an artifact of the kernel size calculation, which must be integer-valued.
bsig = linspace(.9,5.1,1000);
bsize = 2*ceil(2*bsig) + 1;
plot(bsig,bsize);
grid on
The significance of these sudden changes can be reduced by explicitly specifying a larger filter size.
rng(1)
A=randn(100,100);
ind=find(A==max(A(:)));
X=linspace(.9,5.1,1000);
dist=0*X;
for i=1:1000
bsize = 2*ceil(4*X(i)) + 1;
B=imgaussfilt(A,X(i),'filtersize',bsize);
dist(i)=B(ind);
end
plot(X,dist,'.')
grid on
I tend to prefer a bit more filter support than the default provides, but as always, the defaults are a compromise between quality and speed.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!