image Post Your Answer


image

Store images in MATLAB

5 years ago in Matlab By Sapna C K


Is it possible to store images in a single array in MATLAB?

All Answers (2 Answers In All)

By Pradeep Sharma Answered 5 years ago

Yes. It is definitely possible to store images in single array or matrix in MATLAB. myFolder = ‘C:Documents and SettingsyourUserNameMy DocumentsMy Pictures’; if ~isdir(myFolder) errorMessage = sprintf(‘Error: The following folder does not exist:n%s’, myFolder); uiwait(warndlg(errorMessage)); return; end filePattern = fullfile(myFolder, ‘*.jpg’); jpegFiles = dir(filePattern); for k = 1:length(jpegFiles) baseFileName = jpegFiles(k).name; fullFileName = fullfile(myFolder, baseFileName); fprintf(1, ‘Now reading %sn’, fullFileName); imageArray = imread(fullFileName); imshow(imageArray); % Display image. drawnow; % Force display to update immediately. end


By Fern G Answered 5 years ago

If you want to store images in cell array, use these: clc; clear all; close all; arr = cell(25,77); % Create Cell array k = 1; % get ‘zero’ 25 image cell array img_folder = (‘E:4th yearProjectImagesChardatabaseSample0’); % Enter name folder and its path filenames = dir(fullfile(img_folder,’*.jpg’)); % Read all image with specified extantion Total_image = numel(filenames); % Count total image for i=1:Total_image j = 1; for j=1:77 f = fullfile(img_folder,filenames(i).name); % Stroe ith image path Output = imread(f); % read image Output = imresize(Output,[11 7]); Output = im2bw(Output); Output = reshape(Output,[],77); % cell array divide by ’77’ Output = im2double(Output); arr{k,j} = Output(1,j); % get all pixel value of ‘Output’ image end k = k+1; end


Your Answer


View Related Questions


asked at 05 Dec, 2019 08:10 in Matlab By Rajiv Bhatia


asked at 25 Apr, 2019 07:18 in Matlab By Prithvi Patel



asked at 02 Feb, 2019 08:12 in Matlab By Aama





asked at 04 Aug, 2018 09:34 in Matlab By Nancy Trivedi