What does patch = imJ(j : (j+patchSize-1) , i:(i+patchSize-1), :) means?
Show older comments
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
Accepted Answer
More Answers (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.
Categories
Find more on Image Category Classification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!