Thread Subject: Fast way to blur a matrix?

Subject: Fast way to blur a matrix?

From: Ironic Prata

Date: 22 Nov, 2009 02:30:12

Message: 1 of 6

I start with a image. It?s divided into blocks. I calculate the average of each block. In another matrix each block of the same area and position is filled with the value of the average.
 So i get a matrix comprised of blocks, with the same value within a block. Scimilar to pixilated image.
 I want to blur that matrix to smooth the edges between blocks
I am doing this using a filter, comprised of a convuluted gaussian, the problem i that it is a bit slow.
Is there a faster way to blur a image?

tks

Subject: Fast way to blur a matrix?

From: Matt Fetterman

Date: 22 Nov, 2009 05:28:04

Message: 2 of 6

"Ironic Prata" <lixodoironic@hotmail.com> wrote in message <hea7nk$pug$1@fred.mathworks.com>...
> I start with a image. It?s divided into blocks. I calculate the average of each block. In another matrix each block of the same area and position is filled with the value of the average.
> So i get a matrix comprised of blocks, with the same value within a block. Scimilar to pixilated image.
> I want to blur that matrix to smooth the edges between blocks
> I am doing this using a filter, comprised of a convuluted gaussian, the problem i that it is a bit slow.
> Is there a faster way to blur a image?
>
> tks

Could consider the Fourier domain, and then filtering out high frequency components. Fourier domain also can be used for the convolution and it is faster than the convolution operator.

Subject: Fast way to blur a matrix?

From: Jan Simon

Date: 22 Nov, 2009 11:52:02

Message: 3 of 6

Dear Ironic Prata!

> I start with a image. It?s divided into blocks. I calculate the average of each block. In another matrix each block of the same area and position is filled with the value of the average.
> So i get a matrix comprised of blocks, with the same value within a block. Scimilar to pixilated image.
> I want to blur that matrix to smooth the edges between blocks
> I am doing this using a filter, comprised of a convuluted gaussian, the problem i that it is a bit slow.
> Is there a faster way to blur a image?

You can use your already working block averaging with smaller blocks. A moving average would do the same (there are some tools for that in the File Exchange).
Good luck, Jan

Subject: Fast way to blur a matrix?

From: Matt

Date: 22 Nov, 2009 14:24:05

Message: 4 of 6

"Ironic Prata" <lixodoironic@hotmail.com> wrote in message <hea7nk$pug$1@fred.mathworks.com>...
> I start with a image. It?s divided into blocks. I calculate the average of each block. In another matrix each block of the same area and position is filled with the value of the average.
> So i get a matrix comprised of blocks, with the same value within a block. Scimilar to pixilated image.
> I want to blur that matrix to smooth the edges between blocks
> I am doing this using a filter, comprised of a convuluted gaussian, the problem i that it is a bit slow.
========

If you insist on using a gaussian for the blur function, make sure that you are exploiting the tensorial nature of the Gaussian, i.e. make sure you filter first along the x-axis, then along the y-axis. Breaking the filtering into 1D operations will make it faster.

As pointed out, it could help to do the filtering in Fourier space, but only if the Gaussian kernel is sufficiently wide. A narrow, truncated Gaussian is more efficiently handled by direct convolution in the non-Fourier domain.

Subject: Fast way to blur a matrix?

From: Ironic Prata

Date: 22 Nov, 2009 16:18:06

Message: 5 of 6

tks guys. will look in to it.

Subject: Fast way to blur a matrix?

From: ImageAnalyst

Date: 23 Nov, 2009 02:09:26

Message: 6 of 6

On Nov 22, 11:18 am, "Ironic Prata" <lixodoiro...@hotmail.com> wrote:
> tks guys. will look in to it.
--------------------------------------------------------------------------------------------------
In the spatial domain, look up the function conv2() and imfilter() in
the image processing toolbox. If you have large images and kernels,
then you can look into doing it in the Fourier domain.

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com