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 次查看(过去 30 天)
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 个评论
John D'Errico
John D'Errico 2023-2-13
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.

请先登录,再进行评论。

采纳的回答

Image Analyst
Image Analyst 2023-2-13
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 个评论
Image Analyst
Image Analyst 2023-2-14
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by