Efficient manipulation of images in memory

Which is the more efficient, to store and manipulate several images in an image cube (M,N,K) or in a cell array of images cell(K,1)? I'm thinking of memory, but other measures of efficiency are welcome.

 Accepted Answer

Jan
Jan on 22 Feb 2011
The answer depends on the values of M*N and K. If K is very large, reserving a single [M*N*K] memory block is expensive and a {K,1} cell of [M*N] blocks should be preferred. For small K, the single memory block can be more efficient.
If M*N is very large, extracting a single picture from the [M*N*K] memory block is expensive, because a data copy is necessary. Then a cell vector can be more efficient - but this depends on the actually procedure applied to the images.
My conclusion: Both of your ideas are good and have benefits. Implement both and share your results here.

1 Comment

Thanks, Jan. I usually use cubes unless I need to change the size of images. Cells make it easier to do that without creating entirely new cubes or arrays. I knew there must be more behind the choice than that.

Sign in to comment.

More Answers (1)

If the images are all the same size, use the cube. If not, you would have to pad the smaller images to the size of the biggest which wastes memory and a cell would be better.
Cubes are better for manipulations. my $0.02

Products

Asked:

Joe
on 22 Feb 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!