DIPimage 2.1 released

I’m pleased to announce we’ve released a new version of DIPimage and DIPlib, with several relevant changes. For a full list of changes, please see the DIPlib website, here I’ll review the most salient changes.

First of all, and most important from a computational point of view, is the replacement of the pseudo-random number generator in DIPlib. We now use the well-known Mersenne Twister pseudo-random number generator (we adapted some of the code in the mtwist-0.8 package by Geoff Kuenning). The new code is only slightly slower than the old code, but produces a pseudo-random sequence with much better properties. The old pseudo-random number generator introduced a very small amount of correlation, meaning that white noise was not really white. The following bit of code illustrates the problem, and also measures execution time:

tic; a = noise(newim(4000,4000)); toc
b = abs(ft(a));
Elapsed time is 1.610197 seconds.

The Fourier transform of Gaussian noise is supposed to be Gaussian noise as well. The output above shows some low-frequency correlation that shouldn’t be there. The same piece of code now yields:

Elapsed time is 1.693894 seconds.

A second important change is the addition of a Windows installer. Furthermore, on MATLAB version 7.2 and newer under Windows it is no longer necessary to put the 3 dynamic libraries libdip.dll, libdipio.dll and libdml*.dll on the Windows search path (either by changing the path or moving them to a central directory). Under these versions of MATLAB we can use the setenv command to change the Windows search path while MATLAB is running. This command is new to MATLAB 7.2. Sadly, this trick does not work on other platforms.

Other visible changes are in the figure windows that display images: the “Step through slices” mode is a lot smoother now; the “Save display…” option remembers the last directory used; the display no longer reverts to the 'grey' color map every time the display range is changed; and the 'zerobased' color map has changed as I discussed in an earlier post.

2 Responses to “DIPimage 2.1 released”

  1. On January 27th, 2010, at 22:29, Mustafa said:

    Hi Cris,

    I am trying DIPImage for the first time. Can you please show me how to copy an image data I have in 1024×1024 float c array into a dip_image object. I tried to use the function dip_ImageGetData() but for some reason I can’t get it to work.

    here is what I did so far:

    dip_Image image;

    dip_IntegerArray dimensions;

    dip_IntegerArrayNew( &dimensions, 2, 0, rg );

    dimensions->array[ 0 ] = 1024;

    dimensions->array[ 1 ] = 1024;

    dip_ImageNew( &image, rg );

    dip_ImageSetType( image, DIP_IMTP_SCALAR );

    dip_ImageSetDataType( image, DIP_DT_SFLOAT );

    dip_ImageSetDimensions( image, dimensions );

    dip_ImageForge( image );

    I have my image data in the array MyImageArray[]

    Best regards


  2. On January 28th, 2010, at 11:06, Cris Luengo said:

    Hi Mustafa,

    What you’ve got so far is correct. Next you’d get the data pointer with dip_ImageGetData(), as you mentioned:

    dip_ImageArray out;
    dip_VoidPointerArray odp;
    dip_sfloat* ptr;
    dip_ImageArrayNew( &out, 1, rg );
    out->array[ 0 ] = image;
    dip_ImageGetData( o, o, o, out, &odp, o, o, rg );
    ptr = (dip_sfloat*)odp->array[ 0 ];

    There is a short-cut in case you only want the pointer to a single image:

    #include "dip_developer.h"
    void* vptr;
    dip__ImageGetData( image, &vptr );
    ptr = (dip_sfloat*)vptr;

    (Note the double underscore in the function name: this is undocumented and unsupported functionality!)

    Remember to use the stride array to index your image:

    dip_IntegerArray stride;
    dip_int x, y;
    dip_ImageGetStride( image, &stride, rg );
    ptr + x * stride->array[ 0 ] + y * stride->array[ 1 ];

Leave a Reply

Your email address will not be published. Required fields are marked *

Note: I moderate all comments. Comments without a clear relation to the text above will not be published.

You can use these HTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">