ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Rotate + Crop versus Crop with angle
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

LikeMike

Spain
13 Posts

Posted - Apr 24 2022 :  11:56:03  Show Profile  Reply
Hello!

There is something wrong with the Crop-function.
If I use:

Img.Proc.Rotate(45);
Img.Proc.Crop(Rect.Left, Rect.Top,Rect.Right, Rect.Bottom );

I get the expected result.

If I use:
Img.Proc.Crop(Rect, 45, ierFast);

The result is not what I expected.
1. the orientation of the rotation is different (Rotate : counterclockwise, Crop : clockwise)
2. even if I set the second code to 315° the cutout is not the same!

The problem is: the first code is much slower than the second one, so it would be nice, if Crop(rect, angle, ..) gives the same result.

Regards
Mike

xequte

38611 Posts

Posted - Apr 25 2022 :  22:00:48  Show Profile  Reply
Hi Mike

1. Unfortunately for historical reasons there is some inconsistency with the directions of rotation values in ImageEn. For crop, the rotation direction is clockwise.

2. That's correct. They use a different method of cropping

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

LikeMike

Spain
13 Posts

Posted - Apr 26 2022 :  03:50:46  Show Profile  Reply
 
2. That's correct. They use a different method of cropping


OK - and what do I have to change here "Img.Proc.Crop(Rect, 45, ierFast);" to get the same result?
Go to Top of Page

xequte

38611 Posts

Posted - Apr 27 2022 :  21:53:26  Show Profile  Reply
Hi

It would be difficult to get the same code using the rotate overload, because you won't know the size of the image until after it has been rotated (i.e. left and top of the crop rect would have to be shifted by an [as yet] unknown amount).

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

LikeMike

Spain
13 Posts

Posted - Apr 28 2022 :  01:11:43  Show Profile  Reply
Yes - that's exactly my problem...
Go to Top of Page

xequte

38611 Posts

Posted - May 03 2022 :  23:21:04  Show Profile  Reply
I have improved the help documentation with a better explanation...

The Rotate and Crop overload rotates the whole image and the crops to a region of interest by adjusting the crop region to account for the rotation.

Consider this image:



And these parameters:

const
  Rotation_Angle = 10;
  Crop_Left      = 220;
  Crop_Top       = 70;
  Crop_Right     = 220 + 170;
  Crop_Bottom    = 70 + 160;

Cropping then rotating:

ImageEnView1.IO.LoadFromFile( 'D:\Tiger.jpg' );
ImageEnView1.Proc.Crop( Crop_Left, Crop_Top, Crop_Right, Crop_Bottom );
ImageEnView1.Proc.Rotate( Rotation_Angle, ierBicubic, clBlack );



Rotating then cropping:

ImageEnView1.IO.LoadFromFile( 'D:\Tiger.jpg' );
// Note the negative rotation value
ImageEnView1.Proc.Crop( Rect( Crop_Left, Crop_Top, Crop_Right, Crop_Bottom ), -Rotation_Angle, ierBicubic );



Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: