如何从matlab中的图像中获取一些部分?

时间:2010-10-18 18:53:07

标签: matlab

我的图像尺寸为512x256。 我想从这张图片中得到一些像切片的部分。 就像我想要I1的尺寸512x50。

2 个答案:

答案 0 :(得分:2)

要拍摄包含前50列和所有行的切片,请执行以下操作

sliceOfImage = originalImage(:,1:50)

要拍摄包含第100至149列的切片,请调用

sliceOfImage = originalImage(:,100:149)

答案 1 :(得分:1)

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.