somebody help me out the following code is throwing some error?

this is the code
clc;
clear all;
imdataPositive={};
imgPath = 'D:\EDU\Project\Images\';
dCell = dir([imgPath '*.jpg']);
for a=1:length(dCell)
baseFileName = dCell(a).name;
fullFileName = fullfile(imgPath, baseFileName);
imdataPositive{a} =imread(fullFileName);
end
%for a=1:length(dCell)
%imageNames = {imdataPositive{a}};
%end
numImages = numel(imdataPositive);
emptyEntry = struct('image',[],'thumbnail',[]);
imageCollection = repmat(emptyEntry,[1 numImages]);
thumbnailSize = 400;
for i = 1:numel(imageCollection)
imageCollection(i).image = imread(imdataPositive{i});
imageCollection(i).thumbnail = imresize(imageCollection(i).image,...
[thumbnailSize,thumbnailSize]);
end
figure;
montage(cat(4,imageCollection.thumbnail));
title('Image Collection');
this is the error
??? Error using ==> strfind
Input strings must have one row.
Error in ==> imread at 329
if (strfind(filename, '://'))
Error in ==> test2 at 19
imageCollection(i).image = imread(imdataPositive{i});

 Accepted Answer

Sai - I think that you are trying to do too many imreads. Note that you initialize imdataPositive as
for a=1:length(dCell)
baseFileName = dCell(a).name;
fullFileName = fullfile(imgPath, baseFileName);
imdataPositive{a} =imread(fullFileName);
end
where each element of imdataPositive is an image. Later in the code (at line 19), you try to do
imageCollection(i).image = imread(imdataPositive{i});
But imdataPositive{i} is already an image! All that you have to do is replace the above
imageCollection(i).image = imdataPositive{i};
Try the above and see what happens!

More Answers (1)

The code you posted does not have strfind() in it - only the error message does. My guess is that filename is empty, zero, or a 2D array. Put filename on it's own line without a semicolon before you call strfind() and see what it spits out to the command line.
filename
location = strfind(filename, '://')
if ~isempty(location)
% We found it!
Or better yet, go here to solve this and every other kind of problem.

Categories

Tags

No tags entered yet.

Asked:

Aps
on 4 Apr 2015

Commented:

Aps
on 5 Apr 2015

Community Treasure Hunt

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

Start Hunting!