What is index out of bound ?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Sir i have two files . When i run these codes I get this error.
duplicate
Attempted to access test(29,258,2); index out of bounds because size(test)=[512,512,1].
Error in duplicate>Segment_Callback (line 337)
cimg(i,j,2) = test(i,j,2);
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in duplicate (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)duplicate('Segment_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
What the error means and how can I solve it? It is very urgent.. Can you please help me soon.
Antworten (1)
Image Analyst
am 23 Apr. 2015
You're trying to assign the green color channel to another image:
cimg(i,j,2) = test(i,j,2);
but it's not a color image and does not have a second color plane. What you should do if you want to have a color image is this:
[rows, columns, numberOfColorChannels] = size(test);
if numberOfColorChannels == 1
% It's a gray scale image. Create a color image from it.
cimg = cat(3, test, test, test);
else
cimg = test; % Already RGB, just assign all color channels to cimg.
end
3 Kommentare
Image Analyst
am 23 Apr. 2015
In place of the whole i,j loop. You obviously can't use that code because it throws an error. My code will not. If you have one with test(i,j,3) get rid of that also.
Siehe auch
Kategorien
Mehr zu Platform and License 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!