You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is likely caused by a mismatch between the value of the filter you are using in C++. As stated in the docs, PillowResize::resize uses values from the enum PillowResize::InterpolationMethods, which has a 1:1 mapping with the resampling filters enum from PIL.
Instead, the cv::InterpolationFlags has a different enumeration, so you are not actually applying the bilinear interpolation but the Lanczos one.
Can you try changing your code to something like this?
{
cv::Mat image = cv::imread("/docker/output_detection_1.png", cv::IMREAD_UNCHANGED);
cv::cvtColor(image, image, cv::COLOR_BGR2RGB);
int target_size = 224;
std::cout << "Size of image in function : " << image.size() << std::endl;
cv::Sizedst_size(target_size, target_size);
int filter = PillowResize::InterpolationMethods::INTERPOLATION_BILINEAR; // <-- value from PillowResize::InterpolationMethods
image = PillowResize::resize(image, dst_size, filter);
return0;
}
cpp code :
#include <PillowResize/PillowResize.hpp>
#include <opencv2/opencv.hpp>
#include
int main()
{
cv::Mat image = cv::imread("/docker/output_detection_1.png", cv::IMREAD_UNCHANGED);
cv::cvtColor(image, image, cv::COLOR_BGR2RGB);
Python Code :
from PIL import Image
import numpy as np
image = Image.open("/workspace/output_detection_1.png")
image = image.convert("RGB")
resized_image = image.resize((224, 224), Image.BILINEAR )
I have dumped the resized image numpy array in file and got significant diff in both the arrays when comparing both the images.
The text was updated successfully, but these errors were encountered: