Error in calculating max(max(corrImageR)) during batch image processing after completing 1st iteration (error on 2nd image to be processed)

2 views (last 30 days)
I'm batch processing images. The algorithm involved the included line of code. The first image processes successfully, but on the 2nd image the following error is given. Note, even when not processing in batches, if an image is processed, and then the code is ran again without clearing variables, clear all, the same error is given.
Subscript indices must either be real positive integers or logicals.
Error in batchExudateAnalysisDR (line 30) [maxIdxR,maxIdyR] = find(corrImageR == max(max(corrImageR)));

Accepted Answer

Image Analyst
Image Analyst on 18 May 2015
Did you redefine max()? Set a breakpoint at that line and when it stops, type this in the command window:
which -all max
whos max
Or try splitting up your code into smaller chunks and examine each one:
maxValue = max(corrImageR(:))
mapOfMaxima = corrImageR == maxValue;
[rowsOfMax, columnsOfMax] = find(mapOfMaxima);
It looks like when you use [maxIdxR, maxIdyR], you might be making the common mistake of thinking (x,y) = (row, column). It is not. They're not the same. find() returns rows, y, first, and the second argument is columns, x. You seem to be reversing that. So you'd want [maxIdxR, maxIdyR], not [maxIdyR, maxIdxR]

More Answers (0)

Community Treasure Hunt

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

Start Hunting!