help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with images loading


From: Andy Buckle
Subject: Re: Problem with images loading
Date: Mon, 21 Mar 2011 12:13:28 +0000

On Mon, Mar 21, 2011 at 11:18 AM, Andy Buckle <address@hidden> wrote:
> On Mon, Mar 21, 2011 at 9:10 AM, olga_kruglova <address@hidden> wrote:
>> Program was running fine and all of the sudden I have problem. When I try to
>> run it gives me an error "error: A(I): Index exceeds matrix dimension.
>> error: called from:
>> error:   Images.m at line 5, column 3"
>> And I haven't change anything. Would it be possible to help me?
>> tifDir='C:\01m_nacl_4v_10hz';
>> filePaths =dir([tifDir '*.tif']);
>> fileNames = {filePaths.name};
>> numberOfImageFiles = numel(fileNames);
>> I = imread( fileNames{1});
>>
>> subtractedSequence = zeros([size(I) numberOfImageFiles],class(I));
>> subtractedSequence(:,:,1) = I;
>>
>> for i = 2 : numberOfImageFiles
>>        priorImage{i-1} = imread([tifDir fileNames{i-1}]);
>>        currentImage{i} = imread([tifDir fileNames{i}]);
>>        subtractedSequence = currentImage{i} - priorImage{i-1};
>>        priorImage = currentImage;
>>        outputFileName = sprintf('Subtraction_%d.tif',i);
>>                           imwrite(subtractedSequence, outputFileName );
>>        end
>> Thank you very much in advance!
>>
>> Olga
>
> I assume you pasted the whole m-file, so "I = imread( fileNames{1});"
> is line 5.
>
> It looks like the call to dir found nothing. It looks like the reason
> for this is that there is a trailing slash missing.
> tifDir='C:\01m_nacl_4v_10hz';
> should be
> tifDir='C:\01m_nacl_4v_10hz\';
>
> (Though, of course, I cannot check that you have the correct path...)
>
> you could put some extra lines in to show the full string being used
> in the call to dir. Then the problem should be clear.

I should also have pointed out that the fullfile function will help
avoid this kind of error. For example

>fullfile('c:','temp','*.tif')
ans = c:\temp\*.tif
>fullfile('c:\','temp','*.tif')
ans = c:\temp\*.tif
>fullfile('c:\temp','*.tif')
ans = c:\temp\*.tif
>fullfile('c:\temp\','*.tif')
ans = c:\temp\*.tif


-- 
/* andy buckle */


reply via email to

[Prev in Thread] Current Thread [Next in Thread]