Reputation: 11
that's a code my prof said but I don't understand it.
A=imread('cameraman'); i=1:4:256; T=A(i,i); imshow(A); figure; imshow(T);
Why does the image just become smaller, and details are not omitted?
Upvotes: 0
Views: 379
Reputation: 1228
Details are being omitted. I'm assuming from the code that the image is 256x256.
The indexing variable i
is being defined with a step of 4, meaning it goes something like this:
i = [1 5 9 13 ... 256];
Then, it is used to index both the row and columns of the matrix A
to create a new matrix T
.
That's why the new image is smaller; T only contains data points from A that are indexed by i
.
As an exercise I recommend varying the step to see how the resulting image changes. Change the step to 1 and you will see that both images are the same size. Change the step to 8 and you will see that the second image is now even smaller than before.
Upvotes: 2