DSPRelated.com
Forums

tiny image filter with large filter

Started by lucy February 18, 2005
HI all,

I am have a tiny image filtering with my 2D Gaussian filter. The Gaussian 
filter is 20 times larger than the tiny input image in both X and Y size.

Are there any methods to speed up my convolution?

Since I just want the same size output as my tiny input image size; can I 
truncate the Gaussian filter to be the same size as the tiny input to make 
the filter and the image the same size, so my convolution will be speed up 
significantly?

I have done some trials but found the truncated results is not even correct 
to approximation. The reason is that my Gaussian is really a wider spread 
comparing with the tiny input image. So truncation make too much accuracy 
loss. Are there any tricks that can help me?

Thanks a lot! 


"Ken Davis" <kendavis@NOSPAM.alum.mit.edu> wrote in message 
news:FB563847E90BDFEE1D59835163543464@in.webx.raydaftYaTP...
> "lucy" <losemind@yahoo.com> wrote in message > news:cv65gp$dt1$1@news.Stanford.EDU... >> HI all, >> >> I am have a tiny image filtering with my 2D Gaussian filter. The Gaussian >> filter is 20 times larger than the tiny input image in both X and Y size. >> >> Are there any methods to speed up my convolution? >> >> Since I just want the same size output as my tiny input image size; can I >> truncate the Gaussian filter to be the same size as the tiny input to >> make the filter and the image the same size, so my convolution will be >> speed up significantly? >> >> I have done some trials but found the truncated results is not even >> correct to approximation. The reason is that my Gaussian is really a >> wider spread comparing with the tiny input image. So truncation make too >> much accuracy loss. Are there any tricks that can help me? >> >> Thanks a lot! >> > > Instead of truncating, try subsampling your Gaussian kernel by a factor of > 20. > > G_new = G(1:20:end,1:20:end) > > Then, study your books and learn what you are doing. >
Thanks a lot Ken. I just found "truncating" worked, it won't lose any accuracy, since if we use: conv2(image, filter, 'same') in Matlab, only the output of size of the tiny image will be returned, let's suppose tiny input image is of WxW size, and the conv2 output using the 'same' option will generate an output of WxW, ... so if I truncate the huge filter to be about 2W x 2W, and zero pad the tiny image to 2W x 2W, then use: conv2(image_zero_padded, filter_truncated, 'same'), it will generate a 2W x 2W output, then I just throw away the paddings and retain the central WxW pixels... this will be precisely what I wanted... ------------------------------------------------------------------- I am happy to know another method: the downsampling method, as you've pointed out -- to downsample the huge filter first... I hope it will be an even better solution. I am not sure I completely understand how to do it... You think it will work after throwing away so much information? Do I need to do any preprocessing and postprocessing before and after it? Which keyword is this technique? Any fast reference in the books? Could you please give me more information? Thanks a lot!