What does patch = imJ(j : (j+patchSize-1) , i:(i+patchSize-1), :) means?
显示 更早的评论
I think it means RGB but I'm not too sure. Why does the j and i has to add increment by patchSize -1?
In front of this code is
for j = 1:height
for i = 1:width
patch = imJ( j : (j+patchSize-1), i:(i+patchSize-1), :);
Thanks in advance
采纳的回答
更多回答(1 个)
Read
doc colon
It's simply a subarray selection of a rectangular area ("patch") from the imj array (undoubtedly an image) patchSize square starting at the corner (i,j==1). There better be some exit code somewhere in the loop or it will error when either i,j are past the upper bounds less the size parameter.
The last dimension colon picks up all the planes so will be 3D array if imJ is RGB although Matlab addressing is general-enough to work with only 2D array as well with the superfluous trailing dimension just as an observation.
类别
在 帮助中心 和 File Exchange 中查找有关 Image Category Classification 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!