Fast convolution of an large image and small mask

2 次查看(过去 30 天)
Hi, I was wondering if it is possile to speed up the convolution of a large image? My image and my mask are not the same size. For example my image has the size 1430 x 1340 (I cut it down a bit) and my mask is 56 x 56. My mask is an aperture of a certain size.
When the blob in my image is very large (covers large part of the image), conv2 and imfilter is taking a very long time. fft2, only works for images of the same size?
Edit: removed code.
Help, I dont have the time to wait 30+ min for each simulation. I need to speed up the convolution somehow? Any idea of how to make this faster?
The idea is to determine how much energy we have in the aperture of certain size (my mask) and find the maximal energy output in my blob. The Aperture is not always circular.

采纳的回答

Naman Chaturvedi
Naman Chaturvedi 2018-8-13
Hi,
A possible solution to the problem can be to zero pad the mask image, find its fft using 'fft2', multiply it with the image's fft and find the ifft using 'ifft2'. So, if 'm' is your mask and 'i' your image, you could zeros pad the mask 'm':
M=zeros(size(i));
M(1:size(m,1),1:size(m,2))=m;
M=uint8(M);
You can proceed further by treating fft of M as your fft of original mask m.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by