Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How can I do

Subject: How can I do

From: axonmania

Date: 10 Jan, 2009 13:26:14

Message: 1 of 4

Hi ,

I need help. I have searched around the net but I haven't found any
solution :(

I have an Image I read them as 512x512 matrix. and I want made
processing that I will get at first 4096 pieces of 8x8 blocks of them
and after the blocks I want get 4096 pieces 1x64 vectors of the 8x8
blocks.

for the first part I have writen

height=512;
width=512;
lf=8;
for a=1:lf:height
      for b=1:lf:width
            imblocks(a:a+lf-1,b:b+lf-1)=i(a:a+lf-1,b:b+lf-1);
      end
end

after than I want get the vectors

with names

v1,v2,.....v4096


but I could not implement it :(


it is posible on Matlab. Where can I find complex examples about that
wise conversations?


Thnaks

Subject: How can I do

From: Wolfgang Schwanghart

Date: 10 Jan, 2009 14:09:02

Message: 2 of 4

Don't do it the way you describe here. My advice is to put all blocks in a cell array

C = mat2cell(I,repmat(8,512/8,1),repmat(8,512/8,1));

then use cellfun to create vectors.

C2 = cellfun(@(x) x(:)',C,'UniformOutput',false);

Don't create a bunch of numbered variables, but keep them in a cell or structure array. You can then assess then easily using the functions cellfun or structfun.

HTH,
Wolfgang


axonmania <murat.gezer@gmail.com> wrote in message <d87c1ea0-d8bb-4d37-9de7-f8923e5b9a79@q30g2000prq.googlegroups.com>...
> Hi ,
>
> I need help. I have searched around the net but I haven't found any
> solution :(
>
> I have an Image I read them as 512x512 matrix. and I want made
> processing that I will get at first 4096 pieces of 8x8 blocks of them
> and after the blocks I want get 4096 pieces 1x64 vectors of the 8x8
> blocks.
>
> for the first part I have writen
>
> height=512;
> width=512;
> lf=8;
> for a=1:lf:height
> for b=1:lf:width
> imblocks(a:a+lf-1,b:b+lf-1)=i(a:a+lf-1,b:b+lf-1);
> end
> end
>
> after than I want get the vectors
>
> with names
>
> v1,v2,.....v4096
>
>
> but I could not implement it :(
>
>
> it is posible on Matlab. Where can I find complex examples about that
> wise conversations?
>
>
> Thnaks
>
>
>

Subject: How can I do

From: Roger Stafford

Date: 10 Jan, 2009 18:05:03

Message: 3 of 4

axonmania <murat.gezer@gmail.com> wrote in message <d87c1ea0-d8bb-4d37-9de7-f8923e5b9a79@q30g2000prq.googlegroups.com>...
> .......
> I have an Image I read them as 512x512 matrix. and I want made
> processing that I will get at first 4096 pieces of 8x8 blocks of them
> and after the blocks I want get 4096 pieces 1x64 vectors of the 8x8
> blocks.
> ......

  Here's another way. Call your original matrix A. Then you can create a matrix B consisting of 4096 columns of 64 elements each, where each of these columns contains the elements from one of the various 8 x 8 blocks in A.

 m = 8; n = 8; p = 64; q = 64;
 [I,J,K,L] = ndgrid(1:m,m*p*(0:n-1),m*(0:p-1),m*p*n*(0:q-1));
 B = reshape(A(I+J+K+L),m*n,p*q);

Is that of any help to you?

Roger Stafford

Subject: How can I do

From: axonmania

Date: 10 Jan, 2009 19:44:11

Message: 4 of 4

Roger thank you for solution..

I have used the solution from wolfgang because it will help me more on
the next steps.


I am now learning more about cells


Thank You


Murat Gezer

Tags for this Thread

No tags are associated with this thread.

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.

Contact us