Bug 401788 - "Scale Image to New Size" - Nearest Neighbor filter generates wrong results while downsampling image
Summary: "Scale Image to New Size" - Nearest Neighbor filter generates wrong results ...
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Unclassified
Component: Resize/Scale Image/Layer (show other bugs)
Version: 4.1.5
Platform: Microsoft Windows Microsoft Windows
: NOR major
Target Milestone: ---
Assignee: Tiar
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-12-05 18:18 UTC by maxtemp
Modified: 2019-04-05 08:33 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description maxtemp 2018-12-05 18:18:56 UTC
Hi, I have found a bug in Scale Image to New Size... When you downsample image with Nearest Neighbor filter you get wrong result. Pixel values are interpolated, instead of being sampled from the nearest neighbor. 

Sample image https://i.imgur.com/koQ0nIh.png 

Wrong result https://i.imgur.com/OFdWrhE.png
Comment 1 Tiar 2019-04-05 08:33:24 UTC
Git commit 57c3194c1c8aaf9b17fd8f080533610c38a626a7 by Agata Cacko.
Committed on 05/04/2019 at 08:33.
Pushed by tymond into branch 'master'.

Fix results of Nearest Neighbour filter

Summary:
Before this patch the NN filter would create intermediate colors
in some circumstances, especially when scaling with the scale <50%.
Now the filter will choose one of the colors around instead of
blending colors around to get the result color.

Test Plan:
- added tests to test the behaviour of NN filter
- testing on the image: http://www.bealecorner.org/red/test-patterns/star-chart-bars144-600dpi.png
- testing on the image from bug report

Reviewers: dkazakov, #krita

Reviewed By: dkazakov, #krita

Tags: #krita

Differential Revision: https://phabricator.kde.org/D20246

M  +34   -13   libs/image/kis_filter_strategy.cc
M  +24   -16   libs/image/kis_filter_strategy.h
M  +7    -2    libs/image/kis_filter_weights_applicator.h
M  +6    -5    libs/image/kis_filter_weights_buffer.h
M  +1    -1    libs/image/kis_transform_worker.cc
M  +208  -21   libs/image/tests/kis_filter_weights_applicator_test.cpp
M  +10   -0    libs/image/tests/kis_filter_weights_applicator_test.h

https://commits.kde.org/krita/57c3194c1c8aaf9b17fd8f080533610c38a626a7