How to crop and resize images?

조회 수: 15 (최근 30일)
Isha Pandya
Isha Pandya 2016년 10월 20일
편집: Swarooph 2016년 10월 20일
I have a folder containing 100 frames. The frames contain human face. I want to crop and resize all the frames so that I could get only faces and the background is eliminated. Then, I want to store all the cropped and resized images in a folder named- "preFrames". I am new to MATLAB. Please provide the code with some explanation.

답변 (1개)

Swarooph
Swarooph 2016년 10월 20일
  1. To crop, use imcrop function. Example here.
  2. To resize, use imresize function. Example here.
  3. To save images, use imwrite function. Example here.
  댓글 수: 2
Isha Pandya
Isha Pandya 2016년 10월 20일
I have a folder containing 100 images. I want to crop images to get only faces in succession. So I need for loop. How to do this ?
Swarooph
Swarooph 2016년 10월 20일
편집: Swarooph 2016년 10월 20일
If you are new to MATLAB I strongly encourage you to learn MATLAB programming basics by accessing the MATLAB Onramp free course . Apart from covering FOR loops, it also talks about various things such as indexing etc. which will prove to be very useful when you are working with images.
In any case, here is the documentation regarding FOR loops.
Take a look at the face detection example in the documentation here to see how to do automatic face detection instead of manual cropping.
The general documentation can be found here where you can search for different things that you might have questions about to look at examples and read about concepts.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by