# Auto cropping and processing photos in a scan of multiple photos

**URL:** https://forum.opencv.org/t/auto-cropping-and-processing-photos-in-a-scan-of-multiple-photos/2312
**Category:** Python
**Created:** [March 22, 2021, 10:11pm UTC](https://forum.opencv.org/t/auto-cropping-and-processing-photos-in-a-scan-of-multiple-photos/2312 "2021-03-22T22:11:45Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Mojomaker](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@Mojomaker](https://forum.opencv.org/u/Mojomaker)
#### Post date: [March 22, 2021, 10:11pm UTC](https://forum.opencv.org/t/auto-cropping-and-processing-photos-in-a-scan-of-multiple-photos/2312/1 "2021-03-22T22:11:45Z")

</div>

I’ve been using cv2 with object detection/classification applications. I need to find a way to separate images (photos) contained in a scan image into separate cropped photos. For example this scan of images:

![Untitled](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/a/abc85b5f6c56b2b443e6d4f83288f6af13b3ccd6.png)

This would be separated into separate images, cropped and rotated correctly. These won’t just be cats or anything I would use object recognition for - I just need a way to detect a probable rectangular box for each. The background would be uniform approximately white (as the scans are color and the background is actually color as well). Any pointers/projects to where I should look using OpenCV?

---

<div class="post-metadata">

### Author: ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)
#### Post date: [March 23, 2021, 10:42am UTC](https://forum.opencv.org/t/auto-cropping-and-processing-photos-in-a-scan-of-multiple-photos/2312/2 "2021-03-23T10:42:05Z")

</div>

1. segmentation. brightness threshold might be good enough, maybe you need to use inRange (or numpy equivalent), maybe you need to work in HSV or similar color space

2. findContours

3. minAreaRect

4. maybe an affine transform to turn each rectangle upright

5. profit
