tags:

views:

35

answers:

2

i have an image I of size 512x256. i want to get some portion like a slice from this image I. like i want I1 of size 512x50 .

+1  A: 

To take a slice that includes the first 50 columns, and all rows, do the following

sliceOfImage = originalImage(:,1:50)

To take a slice that includes columns 100 to 149, call

sliceOfImage = originalImage(:,100:149)

etc.

Jonas
A: 
x = [1:50]; % define the scope of x-axis (the "columns") for the portion of the image
y = [1:512]; %define the scope of y-axis (the "rows") for the portion of the image

I1 = I(x,y,:); % Create I1, the desired portion of the image. Assuming the original image is of RGB and you need to access all 3 colors. 
YYC

related questions