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:
image division into subimages

Subject: image division into subimages

From: St.Ivanov

Date: 10 Jun, 2012 12:54:07

Message: 1 of 4

Hi, does anybody know how a grayscale image can be divided into 64x64 blocks (subimages)?

Subject: image division into subimages

From: Nasser M. Abbasi

Date: 10 Jun, 2012 13:28:33

Message: 2 of 4

On 6/10/2012 7:54 AM, St.Ivanov wrote:
> Hi, does anybody know how a grayscale image can be divided into 64x64 blocks (subimages)?

you can try mat2tiles or mat2cell

--Nasser

Subject: image division into subimages

From: St.Ivanov

Date: 10 Jun, 2012 15:48:07

Message: 3 of 4

"Nasser M. Abbasi" <nma@12000.org> wrote in message <jr27e0$ncl$1@speranza.aioe.org>...
> On 6/10/2012 7:54 AM, St.Ivanov wrote:
> > Hi, does anybody know how a grayscale image can be divided into 64x64 blocks (subimages)?
>
> you can try mat2tiles or mat2cell
>
> --Nasser

OK, here is what exactly I have to do:
I have an image and I have to divide it into 64 blocks of 32x32 each and address them from K1 to K8 so that I can call each separately and apply operations on them.
I read that mat2cell can divide an image in this way:

C=mat2cell(I,[32],[32]) but C is a 8x8 cell array with each cell storing a 32x32 submatrix of I. How can I assign a name to each of the blocks using this sintax and how would this look like a loop.

Thanks a lot.

Subject: image division into subimages

From: Matt J

Date: 10 Jun, 2012 16:36:07

Message: 4 of 4

"St.Ivanov" wrote in message <jr2fjn$374$1@newscl01ah.mathworks.com>...
>
> I read that mat2cell can divide an image in this way:
> C=mat2cell(I,[32],[32]) but C is a 8x8 cell array with each cell storing a 32x32 submatrix of I.
==============

No, mat2cell can't do this. Not with the convenient syntax you've shown as the following demonstration shows:

>> I=rand(8*32);
>>
>> C=mat2cell(I,[32],[32]);
Error using mat2cell (line 107)
Input arguments, D1 through D2, must sum to each dimension of the input matrix size, [256 256].'



However, mat2tiles will let you do something very similar:

http://www.mathworks.com/matlabcentral/fileexchange/35085-split-nd-array-into-equal-sized-cells


>How can I assign a name to each of the blocks using this sintax and how would this look like a loop.
=======

You wouldn't assign a name to each cell separately (that would be poor and awkward practice). You index them, as in the following

for i=1:numel(C)
 C{i}=myfunc(C{i})
end

Or equivalently, you use cellfun

C=cellfun(@myfunc,C,'uniformoutput',0);

Tags for 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