How to get part of an image from Matlab?

I have a 512x256 image i. I want to get a part similar to the fragment from this image I. how I want I1 512x50 in size.

+3
source share
2 answers

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

sliceOfImage = originalImage(:,1:50)

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

sliceOfImage = originalImage(:,100:149)

and etc.

+2
source
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. 
+1
source

Source: https://habr.com/ru/post/1770172/


All Articles