Sub images in Matlab

Sub images in matlab can be extracted with <image>(<vertical coordinates>,<horizontal coordinates>,<mode>). Where :

vertical coordinates are in the range starting coordinate : ending coordinate
horizontal coordinates are in the range starting coordinate : ending coordinate
mode blank for Black and White Image and : for RGB(Color) Image

Example 1 : (for Black and White Image):

>> a = imread('Desert.jpg');
>> b = a(200:500,300:700); % vertically from 200 to 500 pixels and horizontally 300 to 700 pixels
>> subplot(1,2,1); imshow(a);
>> subplot(1,2,2); imshow(b);

Example 2 : (for Color Image):

>> a = imread('Desert.jpg');
>> b = a(200:500,300:700,:); % vertically from 200 to 500 pixels and horizontally 300 to 700 pixels (: for color)
>> subplot(1,2,1); imshow(a);
>> subplot(1,2,2); imshow(b);

Output:

Original Image Sub Image
Example 1
Example 2