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
 TIEBitmap.Resample image shift with TResampleFilter.rfFastLinear
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Nick Brett

United Kingdom
6 Posts

Posted - Feb 05 2025 :  05:25:08  Show Profile  Reply
I have a TIEBitmap image with ie24RGB PixelFormat, pixel dimensions 152 width x 666 height. I want to resample the image to 152 width x 1998 height (stretch in the Y direction). I've checked and can see that the rfNearest and rfLanczos3 sample filters work exactly as I'd expect with no apparent errors, but the rfFastLinear sample filter shifts the image slightly. For instance the pixel (130, 642) in the original image should move to (130, 1928) in the stretched image, but the rfFastLinear sample filter instead moves the pixel to (130, 1926). These are real-world pictures being used for curation of objects, so it does matter. I haven't checked to see if a similar error occurs in the X direction, or to see if the other filters have similar errors.

I've attached a zip file with images that make the difference between the rfNearest and rfFastLinear sample filters obvious, with a black cross at the above pixel coordinates.

attach/Nick Brett/20252552219_TIEBitmap rfFastLinear Resample Error.zip
3.2 KB

foxdingding

78 Posts

Posted - Feb 05 2025 :  19:42:45  Show Profile  Reply
I also noticed this issue, there are similar errors in the X direction. I am not using rfFastLinear now.
Go to Top of Page

xequte

38857 Posts

Posted - Feb 06 2025 :  17:01:17  Show Profile  Reply
The fast linear resampling algorithm creates a new pixels from a linear interpolation of pixel x+0 and pixel x+1 (or y+0 and y+1), so the right border or bottom borders have to interpolate with themselves when enlarging (as there are no further pixels). This results in simple duplication and causes the image content to be offset. For this reason, rfFastLinear should not be used when accurate measurement/positioning is required.

We will add a warning to the documentation.

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