Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

How to divide image into three equal parts?

Asked by Anyaya on 20 Apr 2013

How to split an image in three equal parts. This image is one Image which contains 3 images layered beneth each other I've tried everything to split them but I'm having difficulties, please help. the size of this image is 1024x396 and its unit8

5 Comments

Image Analyst on 20 Apr 2013

What do you mean? Are you dealing with a gray scale image or a 3D true color RGB image? Like each color plane of an RGB image is a layer? Or do you mean that you want to split the image up vertically or horizontally into the top third, middle third, or bottom third (like Azzi did for a gray scale image), or left third, middle third, and right third? Please clarify.

Jurgen on 21 Apr 2013

Then they are not "layered" they are stacked. Have you tried imcrop()?

Anyaya

Products

No products are associated with this question.

1 Answer

Answer by Azzi Abdelmalek on 20 Apr 2013
Edited by Azzi Abdelmalek on 20 Apr 2013
Accepted answer
[n,m]=size(im)   % im is your image
id=fix(n/3)
im1=im(1:id,:);
im2=im(id+1:2*id,:);
im3=im(2*id+1:n,:);

2 Comments

Image Analyst on 21 Apr 2013

Like he said, im is your image variable. In your code you might have read in an image with imread like this

im = imread(fullFileName);

What variable name are you using instead of im in your code?

Azzi Abdelmalek

Contact us