# Line prob at o2

2 views (last 30 days)
Muhammad Masud Rana on 16 Nov 2021
Commented: Cris LaPierre on 23 Nov 2021
image2= o2{120}
Cris LaPierre on 23 Nov 2021
original question
Can anyone help me to understand in the line 5 why it is using 136?
m2 = i2(201:808,201:808);
n2 = imbinarize(m2,0.6);
o2 = mat2cell(n2,[32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32],[32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32]);
image2= o2{136}
c = normxcorr2(image1,image2);
[ypeak, xpeak] = find(c==max(c(:)));
yoffSet = ypeak-size(image1,1);
xoffSet = xpeak-size(image2,2);
figure
imshow(image2);
imrect(gca, [xoffSet+1, yoffSet+1, size(image1,2),size(image1,1)]);

Cris LaPierre on 16 Nov 2021
It is using linear indexing to extract the 136th cell from o2. Linear indexing counts down the rows, column by column. Item 136 is in the cell in the 3rd row, 8th column. You can learn more here and here.
You can use ind2sub to convert a linear index to the more familiar (m,n) syntax.
m2 = i2(201:808,201:808);
n2 = imbinarize(m2,0.6);
o2 = mat2cell(n2,[32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32],[32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32]);
[row,col] = ind2sub(size(o2),136)
row = 3
col = 8
##### 2 CommentsShowHide 1 older comment
Cris LaPierre on 23 Nov 2021
Looks like most of the original question has been edited away. Added a comment back in with the original question so that the answer makes sense.