Seite **1** von **1**

### ex 1 p3

Verfasst: **31. Okt 2008 22:02**

von **Dragon**

Has anybody an idea how to do the downsample and upsample without loops ?

I would need one loop to iterate over the 4x4 matrix blocks.

Is there some command for handling the matrix as block matrizes?

I'm glad for any advise

### Re: ex 1 p3

Verfasst: **1. Nov 2008 11:47**

von **C.**

The key idea is to use "vectorization" instead of loops, a general concept to write smarter and of course faster code.

Have a look at the "vectorization guide"

http://www.mathworks.com/support/tech-n ... /1109.html.

### Re: ex 1 p3

Verfasst: **1. Nov 2008 16:45**

von **Dragon**

thank you for your help.

I've read the whole guide. But there is no special idea I get from it how I can do this.

Like I've written before I know how to extract the blocks but there is still no idea how to iterate over them without

any loop.

Or are there some special commands to use instead of pure indexing?

### Re: ex 1 p3

Verfasst: **1. Nov 2008 18:56**

von **C.**

No, you don't.

You wrote:

I would need one loop to iterate over the 4x4 matrix blocks.

You mean 2x2 blocks?

You do not have to build these patches explicitly.

Have a look at

http://www.mathworks.com/company/newsle ... atrix.html,

particularly at the ":" and "end" operator.

I will not give away the whole solution, but isn't the downsampled image just

the sum of four matrices of size n/2 X n/2 (plus a multiplication)?

### Re: ex 1 p3

Verfasst: **2. Nov 2008 11:38**

von **Dragon**

Thank you very much !!

Now I got the right idea.

I was to concentrated on extracting the 2x2 blocks (of course) I think.