What's wrong with scaling?

asked 2015-02-02 05:24:29 -0600

rafafirenze gravatar image

Hello.

I'm trying to scale an image into 4x4 pixels by this code:

    Mat image4x4;

    vector<int> compression_params;
    compression_params.push_back(CV_IMWRITE_PNG_COMPRESSION);
    compression_params.push_back(9);

    resize(imageFromFile, image4x4, Size(4,4), INTER_CUBIC);
    imwrite("/Users/macuser/Desktop/4x4/"+names.at(i), image4x4, compression_params);

The result is this:

image description

but if I do it with GIMP (in 'cubic' as well), the result is:

image description

I don't know what factor I'm not considering when scaling... do you have any clue?

Thank you very much. Regards.

edit retag flag offensive close merge delete

Comments

2

There can be several reasons

  • The compression parameter is different, I would only compare stuff WITHOUT compression!
  • Rounding errors to make the function calculate faster

I would start by comparing implementations, that will shed light on the result. Also, could you give the original 4 pixels from which you start your analysis?

StevenPuttemans gravatar imageStevenPuttemans ( 2015-02-02 06:18:55 -0600 )edit

Hi @StevenPuttemans, thanks for your reply.

  1. I have tried with no interpolation as well. The same result happened.
  2. I can't publish the image because it's copyrighted. I made another example: link text
rafafirenze gravatar imagerafafirenze ( 2015-02-02 07:12:38 -0600 )edit

Okay your image is still unclear to me. WHAT region are you expendaning?

StevenPuttemans gravatar imageStevenPuttemans ( 2015-02-02 07:16:01 -0600 )edit

The whole image.

rafafirenze gravatar imagerafafirenze ( 2015-02-02 07:23:31 -0600 )edit

O now I get it, you are parsing a complete image in 16 pixels? O_O why would you need that :P

StevenPuttemans gravatar imageStevenPuttemans ( 2015-02-02 07:26:25 -0600 )edit

hahahaha :) I need it for a game

rafafirenze gravatar imagerafafirenze ( 2015-02-02 07:35:00 -0600 )edit
1

Well, you are comparing the resize algorithm of two different softwares.. there is no clue as to which one is working better.

What I'd do now would be to resize the image sequentially by a reasonable ratio (first 1/2, then 1/4 and so on) and compare results in both softwares. This might help you understand better what is going on.

Pedro Batista gravatar imagePedro Batista ( 2015-02-02 11:09:27 -0600 )edit