https://github.com/timgoll/matlab_image_crop
extracts four-point-image out of any given image array and rescales it to a defined resolution
https://github.com/timgoll/matlab_image_crop
Last synced: 4 months ago
JSON representation
extracts four-point-image out of any given image array and rescales it to a defined resolution
- Host: GitHub
- URL: https://github.com/timgoll/matlab_image_crop
- Owner: TimGoll
- Created: 2018-10-19T09:41:03.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-10-19T10:25:46.000Z (over 7 years ago)
- Last Synced: 2025-02-23T09:23:29.241Z (over 1 year ago)
- Language: Matlab
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Matlab Image Crop & Rescale
This extracts any four-point-image out of any given input image array and rescales it to a defined resolution.
## Syntax
```matlab
img_out = crop_image(img_in, coordinates_x, coordinates_y, resolution)
```
`img_in`: any single color image array, if you plan on using an rgb image, you have to pass the image three times through this function.
`coordinates_x`: x edge coordinates of the four point shape defining the edge of the new image.
`coordinates_y`: y edge coordinates of the four point shape defining the edge of the new image.
`resolution`: resolution of the new image
## Example
```matlab
img = imread('path/to/image.png');
img_cut_red = crop_image(img(:,:,1), [66, 2468, 2479, 70], [90, 100, 1436, 1460], [1920, 1080]);
img_cut_green = crop_image(img(:,:,2), [66, 2468, 2479, 70], [90, 100, 1436, 1460], [1920, 1080]);
img_cut_blue = crop_image(img(:,:,3), [66, 2468, 2479, 70], [90, 100, 1436, 1460], [1920, 1080]);
```
## Edge point order
Here's a small example of the edge points
```
[x1, y1]
+----------_______ [x2, y2]
/ --------+
| \
/ \
+------_________ \
[x4, y4] -----------------+
[x3, y3]
```