The length of column 1 in bboxout is an unknown, how do I adjust my code to output each iteration of ROI_RGB?
If I use figure, imshow in the for loop each image is displayed, however I need to acces the data for each image seperately outside of the function.
function [ROI_RGB] = cleanup(bboxout, I1)
for i=1:length(bboxout)
%Crop out region of interest
ROI_RGB = imcrop(I1, bboxout(i,:));
end
end

 채택된 답변

Ameer Hamza
Ameer Hamza 2020년 5월 2일
편집: Ameer Hamza 2020년 5월 2일

1 개 추천

Use cell array
function [ROI_RGB] = cleanup(bboxout, I1)
ROI_RGB = cell(1, size(bboxout,1));
for i=1:size(bboxout,1)
%Crop out region of interest
ROI_RGB{i} = imcrop(I1, bboxout(i,:));
end
end
You can access elements of cell array using brace indexing
ROI_RGB{1} % first element
ROI_RGB{2}
..
..
ROI_RGB{end}

댓글 수: 4

Joe Beard
Joe Beard 2020년 5월 2일
Thanks for the reply!
Tried adding this and getting the below error
I will debug in the morning haha
Ameer Hamza
Ameer Hamza 2020년 5월 2일
I have updated the code. length() is actually an ambighious function. size() and numel() should be preferred over length().
Joe Beard
Joe Beard 2020년 5월 3일
Thanks for the help Ameer. The updated code is now giving me the below error I dont really understand, I think I need to do some more research into cell arrays!
Ameer Hamza
Ameer Hamza 2020년 5월 3일
편집: Ameer Hamza 2020년 5월 3일
ISoR is a cell array. To display an image, you need to use indexing
imshow(ISoR{1}) % display first image
imshow(ISoR{2})
..

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

질문:

2020년 5월 2일

편집:

2020년 5월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by