## ex 1 p3

Moderator: Computer Vision 2

Dragon
Mausschubser
Beiträge: 80
Registriert: 18. Apr 2006 15:36

### ex 1 p3

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?

C.
Mausschubser
Beiträge: 64
Registriert: 29. Nov 2004 23:14

### Re: ex 1 p3

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.

Dragon
Mausschubser
Beiträge: 80
Registriert: 18. Apr 2006 15:36

### Re: ex 1 p3

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?

C.
Mausschubser
Beiträge: 64
Registriert: 29. Nov 2004 23:14

### Re: ex 1 p3

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)?

Dragon
Mausschubser
Beiträge: 80
Registriert: 18. Apr 2006 15:36

### Re: ex 1 p3

Thank you very much !!
Now I got the right idea.
I was to concentrated on extracting the 2x2 blocks (of course) I think.