Hi Hyeonho,
I assume you want to iteratively find the cross correlation between template-image pairs from a given cell array.
Assuming the code for finding the normalized cross correlation is correct, the out-of-bounds error most likely arises while reading the second image (‘imageb’):
imageb=imread(str2num{1,i+1})
The loop counter for the second ‘for’ loop runs till the end of the data array, when ideally it should run for one index less than the end (end being the last column index of the cell array) such that ‘i+1’ remains a valid index throughout the execution of the loop. Currently, it may be the case the ‘i+1’ evaluates to ‘end+1’ which when used to index the cell array, results in an out-of-bounds error.
The usage for ‘str2num’ is ambiguous in context of your question, but providing the data you have used, or a minimum reproducible example would be beneficial.
Please refer to the following MATLAB documentation for further reference: