Line prob at o2

2 views (last 30 days)
image2= o2{120}
  1 Comment
Cris LaPierre
Cris LaPierre on 23 Nov 2021
original question
Can anyone help me to understand in the line 5 why it is using 136?
i2 = imread('00020361.bmp');
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);
figure, surf(c), shading flat
[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)]);

Sign in to comment.

Accepted Answer

Cris LaPierre
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.
i2 = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/802529/00020361.bmp');
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 Comments
Cris LaPierre
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.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!