Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why cv::resize with CV_8S and CV_32S type was disabled? #7862

Open
logic1988 opened this issue Dec 15, 2016 · 3 comments
Open

Why cv::resize with CV_8S and CV_32S type was disabled? #7862

logic1988 opened this issue Dec 15, 2016 · 3 comments
Labels

Comments

@logic1988
Copy link
Contributor

Using cv::resize function with cv::Mat in CV_8S and CV_32S type will cause an error:
opencv/modules/imgproc/src/imgwarp.cpp:3368: error: (-215) func != 0 in function resize
After review of the source code I found:

    static ResizeFunc linear_tab[] =
    {
        resizeGeneric_<
            HResizeLinear<uchar, int, short,
                INTER_RESIZE_COEF_SCALE,
                HResizeLinearVec_8u32s>,
            VResizeLinear<uchar, int, short,
                FixedPtCast<int, uchar, INTER_RESIZE_COEF_BITS*2>,
                VResizeLinearVec_32s8u> >,
        0,
        resizeGeneric_<
            HResizeLinear<ushort, float, float, 1,
                HResizeLinearVec_16u32f>,
            VResizeLinear<ushort, float, float, Cast<float, ushort>,
                VResizeLinearVec_32f16u> >,
        resizeGeneric_<
            HResizeLinear<short, float, float, 1,
                HResizeLinearVec_16s32f>,
            VResizeLinear<short, float, float, Cast<float, short>,
                VResizeLinearVec_32f16s> >,
        0,
        resizeGeneric_<
            HResizeLinear<float, float, float, 1,
                HResizeLinearVec_32f>,
            VResizeLinear<float, float, float, Cast<float, float>,
                VResizeLinearVec_32f> >,
        resizeGeneric_<
            HResizeLinear<double, double, float, 1,
                HResizeNoVec>,
            VResizeLinear<double, double, float, Cast<double, double>,
                VResizeNoVec> >,
        0
    };

This array corresponds to the type of Mat:

#define CV_8U   0
#define CV_8S   1
#define CV_16U  2
#define CV_16S  3
#define CV_32S  4
#define CV_32F  5
#define CV_64F  6
#define CV_USRTYPE1 7

The array value associated with CV_8S and CV_32S is 0, which led to error.
cv::resize is an important function, but the bug seems to exist for a long time, which have any special reasons?

@alalek
Copy link
Member

alalek commented Dec 15, 2016

Do you have real use cases for these formats, especially with linear interpolation?
There are more relevant formats:
32S -> 32F
8S -> 16S

@logic1988
Copy link
Contributor Author

Yes, but I am very surprised why 16S can, but 8S and 32S but not.

@HGuillemet
Copy link

CV_32S and CV_8S are supported by opencv and geometric transformations are quite basic features everyone uses.
Of course there are use cases where we want to rescale 32S or 8S images.
Would it really clutter the library too much to add support for these types ?
Please consider adding this support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants