Question

I resized an image with scale of 0.25 then upscaled it using scale of 4.

imageReduced = imresize(imageOriginal, 0.25, 'nearest');
imageGenerated = imresize(imageReduced, 4, 'nearest');

I want to calculate mean square error between imageOriginal and imageGenerated so they must have same height x width values. But after downscale and upscale operations image size changes slightly because of the division.

For example;

size of imageOriginal is 4811 x 6449 and size of imageGenerated is 4812 x 6452

How can I make downscale and upscale operations to make imageGenerated same size with imageOriginal to calculate mean square error between them?

Était-ce utile?

La solution

imresize support resize with fixed number of cols and rows: imresize(img, [rows, cols]). You can use this function variant for second resize.

imageReduced = imresize(imageOriginal, 0.25, 'nearest');
imageGenerated = imresize(imageReduced, size(imageOriginal), 'nearest');
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top