Permalink
Cannot retrieve contributors at this time
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?
5011_Big_Data/overheadOnion.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
25 lines (21 sloc)
586 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% 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* |