开发者

how to get some portion from an image in matlab?

开发者 https://www.devze.com 2023-01-20 20:32 出处:网络
i have an image I of size 512x256. i want to get some portion like a slice fro开发者_如何转开发m this image I.

i have an image I of size 512x256. i want to get some portion like a slice fro开发者_如何转开发m this image I. like i want I1 of size 512x50 .


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.


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. 
0

精彩评论

暂无评论...
验证码 换一张
取 消