Cykooz / fast_image_resize

Rust library for fast image resizing with using of SIMD instructions.
Apache License 2.0
284 stars 25 forks source link

Inaccurate colors appear in the corners of the image after scaling #33

Closed LazyIonEs closed 3 months ago

LazyIonEs commented 3 months ago

我通过resizer.resize方法将此512512的图片缩放到192192,缩放算法使用了Lanczos3,缩放后的图片四角出现了与原图不一致的颜色,我在使用resize时,同样适用了Lanczos3,但并没有这个情况,麻烦看一下这个是什么原因

I scaled this 512512 image to 192192 using the resizer.resize method. The scaling algorithm used Lanczos3. The four corners of the scaled image had inconsistent colors with the original image. When I used resize, I also applied Lanczos3, but this problem did not occur. Please take a look at what is the reason

与原图对比 - Compare with original image image

缩放之前 - Before scaling 512

缩放之后 - After scaling asdasd

Cykooz commented 3 months ago

What version of fast_image_resize are you using?

LazyIonEs commented 3 months ago

What version of fast_image_resize are you using?

4.0.0

Cykooz commented 3 months ago

This is a known disadvantage of such filters (bicubic filters, lanczos3). This effect is called "ringing" (ghost-borders). You may use one of bilinear filters if this effect is not appropriate for you.

I don't know why in the "resize" crate this effect is almost invisible for RGBA images. But for images without alpha channel this effect is the same as for the fast_image_resize.

LazyIonEs commented 3 months ago

我参考了squooshresize的调用,当我启用了premultiplycolor_space_conversion,所得到的结果非常的好,比较符合我的需求,但是相比于reszie,我更想使用fast_image_resize,因为这对于我这个新手来说简单很多,是个很不错的开源库,我不知道这对你是否有帮助。我会尝试其他的过滤器,看看能不能达到我想要的效果

I referred to the call of resize in squoosh. When I enabled premultiply and color_space_conversion, the results were very good and more in line with my needs. However, compared to reszie, I would rather use fast_image_resize because it is much simpler for a novice like me and is a very good open source library. I don't know if this is helpful to you. I will try other filters to see if I can achieve the effect I want.

squoosh - resize ic_launcher_resize_resize_Lanczos3

fast_image_resize ic_launcher_resize_fast_image_resize_Lanczos3

LazyIonEs commented 3 months ago

我尝试使用了fast_image_resize中的MitchellCatmullRom,他们也出现了你所说的"ringing",这个结果对我来说很不好,对于"ringing",Mitchell相比于CatmullRom来说要少很多

I tried using Mitchell and CatmullRom in fast_image_resize, and they also had the "ringing" you mentioned. This result is not good for me. Mitchell has much less "ringing" than CatmullRom.

Mitchell ic_launcher_resize_Mitchell

CatmullRom ic_launcher_resize_CatmullRom

Cykooz commented 3 months ago

Mitchel and CatmulRom are bicubic filters, they also have this effect.

LazyIonEs commented 3 months ago

Mitchel and CatmulRom are bicubic filters, they also have this effect.

Yes, I misunderstood what you meant. I used Bilinear for testing, but the clarity is not as good as Lanczos3, which may not meet my needs. Thank you.

LazyIonEs commented 3 months ago

If this problem cannot be solved, should this issue be closed?

Cykooz commented 3 months ago

No, this is a known property of such filters. You may use bilinear filters or make yoursefl custom filter. There is no the one good filter for all cases. You have to choose filter for particular case.

LazyIonEs commented 3 months ago

No, this is a known property of such filters. You may use bilinear filters or make yoursefl custom filter. There is no the one good filter for all cases. You have to choose filter for particular case.

好的,谢谢 OK, thanks