how to resolve this error "Index exceeds matrix dimensions."
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I am implementing HOG and while computing the cell histograms the code give me this error. Here is the code.
% =================================
% Compute Cell Histograms
% =================================
% Computes the histogram for every cell in the image. We'll combine the cells
H = [];
% Create a three dimensional matrix to hold the histogram for each cell.
histograms = zeros(hogParameters.numVertCells, hogParameters.numHorizCells, hogParameters.numBins);
% For each cell in the y-direction...
for row = 0:(hogParameters.numVertCells - 1)
% Compute the row number in the 'img' matrix corresponding to the top
% of the cells in this row. Add 1 since the matrices are indexed from 1.
rowOffset = (row * hogParameters.cellSize) + 1;
% For each cell in the x-direction...
for col = 0:(hogParameters.numHorizCells - 1)
% Select the pixels for this cell.
% Compute column number in the 'img' matrix corresponding to the left
% of the current cell. Add 1 since the matrices are indexed from 1.
colOffset = (col * hogParameters.cellSize) + 1;
% Compute the indices of the pixels within this cell.
rowIndeces = rowOffset : (rowOffset + hogParameters.cellSize - 1);
colIndeces = colOffset : (colOffset + hogParameters.cellSize - 1);
% Select the angles and magnitudes for the pixels in this cell.
cellAngles = angles(rowIndeces, colIndeces); --> error line
cellMagnitudes = magnitude(rowIndeces, colIndeces); --> error line
% Compute the histogram for this cell.
% Convert the cells to column vectors before passing them in.
histograms(row + 1, col + 1, :) = getHistogram(cellMagnitudes(:), cellAngles(:), hogParameters.numBins);
end
At the cellAngles and cellMagnitude it shows error. Kinldy someone resolve this error.
I shall be very thankful for the kind act of consideration.
4 Kommentare
Walter Roberson
am 24 Mär. 2019
Bearbeitet: Walter Roberson
am 24 Mär. 2019
This code appears to rely on functions from https://github.com/buzkent86/HLT_Tracker/blob/master/getHistogram.m
Walter Roberson
am 24 Mär. 2019
When I test with a random image, I am not encountering any problem. I have attached my test code.
The problem might depend upon the image you are using. You should dbstop if error and find out which image is causing you problems, and attach that image.
Antworten (0)
Siehe auch
Kategorien
Mehr zu Histograms finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!