Seam carving an algorithm for content-aware image resizing.
The utility was written to compress photos without losing quality in order to lighten the load on the devices of PromoCat users.
More about seam carving algorithm: wiki
Launch via CLI. Format: java Main -in {in} -out {out} -width {width} -height {heigth}
- in - input file name in .png format
- out - output file name in .png format
- width - the number of pixels to crop in width
- height - the number of pixels to crop in height
- Input image (crop width 125, height 50)
- Output image
- Input image (crop width 100, heigth 30)
- Output image
-
Calculate the energy of all pixels.
-
Find the minimum energy path from top to bottom.
-
Remove seam.
-
Similarly, horizontally, paths are searched from left to right and the path is deleted.
-
Energy:
- Seam: