Page 1 of 1

Crop and tile picture for ML

Posted: 2020-03-17T09:47:48-07:00
by littlenode
Hi there,
I just got a recommendation to use Imagemagick and i would love to get some info how to tackle this problem.
Im having a picture with 8x8 tiles with a white border around it.


I messured the coordinates are as followed: Left top corner=78,69, Right top corner=513.0,69.0, Left bottom corner=78.0,504.0, Right bottom corner=513.0,504.0

I would like to crop that box and then cut out 8x8 tiles each 576x576px in size.

How could i achive that? I checked the guide and i dont quite get it.

Re: Crop and tile picture for ML

Posted: 2020-03-17T12:17:35-07:00
by fmw42
try either

Code: Select all

convert img.png -fuzz 10% -trim +repage -crop 8x8@ x_%02d.png

Code: Select all

convert img.png -crop 435x435+78+69 +repage -crop 8x8@ x_%02d.png

The first does an automatic trim to remove the white and then gets the best 8x8 set of blocks to fix your trimmed region.

In the second, ImageMagick does a crop using WxH+X+Y. So I had to use your top left and bottom right corner coords to compute WxH and then the top left corner for X,Y.