what (:, :, :) syntax does?
Show older comments
Hi, I'm new in MatLab and my teacher gave us a code to crop images and split them into his RGB components. This section it's suposed to crop the image (I1) I think (am I right?) and display the cropped image (I2)
u=round(ginput(2));
P12 = u(1,2);
P22 = u(2,2);
P11 = u(1,1);
P21 = u(2,1);
I2=I1(P12:P22,P11:P21,:);
figure
imshow(I2)
axis equal
I think I know what the first line does, it gets two inputs from the mouse and then round it to the nearest integer to finally save them into a vector 'u' right?, in that case, my doubt is what those u(1,2) means, how do they work? what are those 1 and 2 into them? And, how that syntax I2=I1(P12:P22,P11:P21,:) works? why is only the : in the final?
I know I could get the answer by reading the documentation, but what documentation do I have to read? Thank you in advance.
2 Comments
Lateef Adewale Kareem
on 24 May 2022
you can use that to index 3 dimensional space in a 4 or higher dimensional data.
The question is why would you need that in the first place
Voss
on 24 May 2022
@Emmanuel Arias Polanco: Here is some documentation you can read that will answer all of those questions:
Accepted Answer
More Answers (0)
Categories
Find more on Image Arithmetic 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!