Skip to content
Permalink
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
%% Example Showing Memory Overhead of Structures
% Copyright 2011 The MathWorks, Inc.
%% Load an image
X = imread('onion.png');
imshow(X)
whos % note that X is a 3-dimensional array
%% Store one plane per field
im1.red = X(:,:,1); % each plane is m x n
im1.green = X(:,:,2);
im1.blue = X(:,:,3);
%% Store one pixel per field
[nr,nc,np] = size(X);
im2(nr,nc).pixel = [0 0 0];
for row = 1:nr
for col = 1:nc
im2(row,col).pixel = reshape(X(row,col,:),1,3);
end
end
clear nr nc np row col
%% Which one is bigger?
whos im*