Page 2 of 2

Re: extracting biggest square from a rotated image

Posted: 2018-08-20T06:57:49-07:00
by manit
ok .
Here is the original 512x512 image -> https://ibb.co/cneSfz
Then I ran this command
convert f0001_01.png -rotate 15 -set option:leg "%[fx:512/(cos(15*(pi/180))+sin(15*(pi/180)))]" -set option:distort:viewport "%[leg]x%[leg]" \( -clone 0 -distort srt 0 \) -gravity center +swap -composite output.png
where f0001_01.png is the above original image.

output.png looked like this -> https://ibb.co/dBcxfz .
Notice that there is a triangle in bottom left corner .

Re: extracting biggest square from a rotated image

Posted: 2018-08-20T07:11:35-07:00
by manit
I am beginning to think that it works as follows
convert f0001_01.png -rotate -15 rotated.png
Then
convert rotated.png -rotate 15 -set option:leg "%[fx:512/(cos(15*(pi/180))+sin(15*(pi/180)))]" -set option:distort:viewport "%[leg]x%[leg]" \( -clone 0 -distort srt 0 \) -gravity center +swap -composite output-with-rotated-input.png

But in such cases also i have observed a white triangle in corner of image .

Can you give a working example ?

Thanks .

Re: extracting biggest square from a rotated image

Posted: 2018-08-20T08:04:17-07:00
by GeeMack
manit wrote: 2018-08-20T07:11:35-07:00But in such cases also i have observed a white triangle in corner of image .
The command you've been using works perfectly. The sample image you provided has a 32 pixel high strip of white along the bottom edge. That's what makes the white triangle in your output.

Re: extracting biggest square from a rotated image

Posted: 2018-08-20T08:08:32-07:00
by manit
GeeMack wrote: 2018-08-20T08:04:17-07:00
manit wrote: 2018-08-20T07:11:35-07:00But in such cases also i have observed a white triangle in corner of image .
The command you've been using works perfectly. The sample image you provided has a 32 pixel high strip of white along the bottom edge. That's what makes the white triangle in your output.
ok .