フィルターのクリア

How to store multiple image vectors into matrix rows?

2 ビュー (過去 30 日間)
Sana Ullah
Sana Ullah 2017 年 6 月 3 日
コメント済み: OO_98 2020 年 5 月 12 日
Hi all, I have a folder which contains 200 BMP images, I am reading all the images, converting each image into a vector and then trying to store these image vectors into a matrix. Following is the code which is self-explanatory, though it looks quite right however when i run the script it give me the following error. Subscripted assignment dimension mismatch.
Error in Readallimages (line 16) immat(437580,k)=imtovector
myFolder = 'C:\Users\Sana\Desktop\DermoscopyImages';
if ~isdir(myFolder)
errorMessage = sprintf('Error: The following folder does not exist:\n%s', myFolder);
uiwait(warndlg(errorMessage));
return;
end
filePattern = fullfile(myFolder, '*.bmp');
bmpFiles = dir(filePattern);
immat=zeros(437580,200);
for k = 1:length(bmpFiles)
baseFileName = bmpFiles(k).name;
fullFileName = fullfile(myFolder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
imageArray = rgb2gray(imread(fullFileName)); %Read image and convert to Gray
imtovector=double(imageArray(:)); %convert 2D image into 1D vector
immat(437580,k)=imtovector %Store image vectors into matrix
imshow(imageArray); % Display image.
drawnow; % Force display to update immediately.
end
Any sort of help in this regard would be highly appreciated. Thanks in advance

採用された回答

Image Analyst
Image Analyst 2017 年 6 月 3 日
You may run out of memory. Why do you think you need to do this? You may not have to. You may be able to just read in and process one image at a time.
  1 件のコメント
Sana Ullah
Sana Ullah 2017 年 6 月 4 日
Sir, Actually what i am trying to do is that, store all these 200 images into single matrix, then build similar matrix of the ground truths and pass this input and output to neural network, train the neural network with these sets of images and then do segmentation of these images using neural network. this would be the first step. as soon as i do this task successfully, i would further add some other functions as activation function in the neurons instead of sigmoid function .

サインインしてコメントする。

その他の回答 (1 件)

Phil
Phil 2017 年 6 月 4 日
編集済み: Phil 2017 年 6 月 4 日
I think the problem is that you are trying to squeeze a 437580 element array into a single array element (the bottom element of the kth column):
immat(437580,k)=imtovector
I think you meant to reference the WHOLE column, not just the last element of the column:
immat(:,k)=imtovector
If the problem persists, check that 'imtovector' really is 437580 elements long.
Also check the orientation of 'imtovector'. You are attempting to store each image as a column, so if 'imtovector' is a row, MATLAB might have an issue with that.
Hope this helps
  3 件のコメント
habtamu miheretie
habtamu miheretie 2018 年 10 月 3 日
hello man, can you share how you solved it, please?
OO_98
OO_98 2020 年 5 月 12 日
hello,Please tell us how you solved the problem. I need that a lot

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by