Menu

Horizontal and vertical lines after resizing

2014-04-24
2014-04-27
  • Bart Butenaers

    Bart Butenaers - 2014-04-24

    Hi everybody,

    I'm having problems with resizing my images, using following code:

    MBFImage image;
    ...
    ResizeProcessor resizeProcessor = new ResizeProcessor(290, 217, false);
    image = image.process(resizeProcessor);

    The resulting image has the correct size as I requested, however it now contains both horizontal and vertical lines:

    my distorted image

    The problem also occurs for other sizes, when keeping the aspect ratio, when specifying filters (like Lanczos3Filter), when normalizing the image, ...

    I assume this is some kind of Moiré pattern? Hopefully somebody knows how I can fix this problem, using pure OpenImaJ.

    Thanks in advance!
    Bart Butenaers

     
  • Jonathon Hare

    Jonathon Hare - 2014-04-24

    Hi Bart,

    Someone asked about this on the mailing list a few weeks ago & I made some fixes in the development version. What version of OpenIMAJ are you using?

    Here's the relevant bit of the reply to the guy on the mailing list:
    ...There seems to be an issue with downsampling sometimes - this problem seems to go all the way back to the original graphics gems code that our version is based on. I've made some changes that will allow the filter to be changed in the ResizeProcessor to something other than BasicFilter, and changed the default to MitchellFilter; in my tests this makes the problem go away. If you can't update to the SNAPSHOT version, then you can always try using the BilinearInterpolation class instead of ResizeProcessor to shrink your images (you might want to blur them a little with an FGaussianConvolve first to avoid aliasing if you do this)...

    Jon

     
  • Bart Butenaers

    Bart Butenaers - 2014-04-25

    Hello Jonathon,

    Thanks for your fast response! I will try out all your suggestions this weekend, and keep you informed about the results afterwards. I'm using the 1.2.1 version (no snapshot).

    Kind regards,
    Bart Butenaers

     
  • Bart Butenaers

    Bart Butenaers - 2014-04-26

    Hi Jonathon,

    I've tested your 3 proposals, and here are the results.

    1. Gaussian blur (OpenImaj 1.2.1)

    image.processInplace(new FGaussianConvolve(2f));
    image.processInplace(new ResizeProcessor(290, 238, false));

    The image becomes a little blurred, but the lines remain (remark: currently my original image also contains only vertical lines):

    blurred image

    2. Bilinear interpolation (OpenImaj 1.2.1)

    image.processInplace(new BilinearInterpolation(290, 238, 1));

    The image gets the correct dimensions, and the annoying lines are eliminated:

    bilinear interpolation

    3. New ResizeProcessor version (OpenImaj 1.0.6-SNAPSHOT)

    image.processInplace(new ResizeProcessor(290, 238, false));

    The image still contains the lines, moreover the colors have changed:

    snapshot version

    Don't know if I've done something wrong with case 3, because the ResizeProcessor instance still contains a BasicFilter (instead of the MitchellFilter you mentioned). I will use the bilinear interpolation (case 2) from now on. But if you want me to test something in the snapshot version, just let me know !!

    Greetings from Belgium,
    Bart Butenaers

     
  • Jonathon Hare

    Jonathon Hare - 2014-04-26

    Can you try with 1.3-SNAPSHOT rather than 1.0.6? Also, in case 2 I don't think you've resized the image, but rather just cropped it - the third parameter to BilinearInterpolation needs to be the scale factor from the new image to the old one.

     
  • Bart Butenaers

    Bart Butenaers - 2014-04-27

    Jonathon,

    Sorry for my mistake with the old 1.0.6 version!

    When I load the 1.3-SNAPSHOT version, it just behaves like you have predicted above. By default the ResizeProcessor still gives me the vertical lines (by default it's filterFunction field is filled with a BasicFilter). When I use your new setFilterFunction method to apply the MitchellFilter, the image has NO LINES ANYMORE.

    So following snippet in version 1.3-SNAPSHOT solves my problem:

    ResizeProcessor resizeProcessor = new ResizeProcessor(290, 238, false);
    resizeProcessor.setFilterFunction(new MitchellFilter());
    image.processInplace(resizeProcessor);

    Thanks for your time, and of course for this great framework !!!!!

    Kind regards,
    Bart Butenaers

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.