Azzera filtri
Azzera filtri

HELP WHY IS THIS NOT WORKING? WHY HAS CODING FORSAKEN ME???? Error: Index must not exceed 5196 error? This occurs when I input a smaller image, why and how to fix?

1 visualizzazione (ultimi 30 giorni)
My questions can be broken down like this:
  1. I have a code that is meant to process the mask of multiple images then count the green dots in those images then graph the number of the green dots vs. region location (that is specified by 12 dividing strips across the image). Is my code accurately doing this?
  2. When I added more images that I think were smaller I got the error in stripMaskImage = masksinusoid(:, col1 : col2); Index in position 2 exceeds array bounds. Index must not exceed 5196. How can I fix this error please? Thank you.
N.
Error: Why do I get the: Index in position 2 exceeds array bounds. Index must not exceed 5196 error
  2 Commenti
John D'Errico
John D'Errico il 13 Feb 2023
The computer gods are always watching over you, keeping notes of who was good, who was bad... Oh. Wait. It is Santa Claus who does that. Anyway, I'm sure the computer gods keep track too. Next time, try kneeling in frong of your keyboard. Can't hurt.

Accedi per commentare.

Risposta accettata

Image Analyst
Image Analyst il 13 Feb 2023
In your (attached) m-file script, you call this line
startingColumns = round(linspace(1, columns+1, 13))
before you ever assigned columns. So of course it doesn't know what columns is (what value it has).
Go back to the working code I gave you in your earlier question, or put that line of code inside the for loop, not outside, so that it uses the columns value for the particular image of that iteration:
for m = 1 : numfiles
fprintf('Processing file #%d of %d : "%s".\n', m, numfiles, allFileNames{m});
MyRGBImage = allFileNames{m};
% Read in image.
imageData = imread(MyRGBImage);
% Get the dimensions of the image.
[rows, columns, numberOfColorChannels] = size(imageData)
% NOW determine the starting and ending columns.
startingColumns = round(linspace(1, columns+1, 13))
endingColumns = startingColumns(2:end) - 1
  3 Commenti
Image Analyst
Image Analyst il 14 Feb 2023
I think it should work but you need to create some "check sample" images where you draw rectangles of known size into the image so you can see if what you get out is what is really there.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by