[Insight-users] exclude pixel values (background) from metrics

Darren Weber darren.weber.lists at gmail.com
Mon Mar 15 15:09:26 EDT 2010


Hi Luis et al.,

Now the ITK library is compiled and installed with the additional features
available.  Now this code will compile:

typedef itk::MeanSquaresImageToImageMetric<iBWImgType,iBWImgType>
MetricType;
MetricType::Pointer metric = MetricType::New();
metric->SetUseFixedImageSamplesIntensityThreshold( true );
metric->SetFixedImageSamplesIntensityThreshold( intensityThreshold );
//metric->SetUseSequentialSampling( true );
//metric->SetUseAllPixels( true );


Now a question arises about the range of values for the
"intensityThreshold".  The input pixel and image typedefs are:

const unsigned short dimImg = 2;
typedef float iPixType;
typedef itk::Image< iPixType, dimImg > iBWImgType;
typedef itk::ImageFileReader< iBWImgType > bwImageReaderType;


The image reader is pulling in .tif images, which ImageMagick identifies as
(see verbose output in attachment):

$  identify testdata/bw/section0003_w1.tif
testdata/bw/section0003_w1.tif TIFF 549x539 549x539+0+0 16-bit Grayscale
DirectClass 615KB 0.010u 0:00.030

When this image is read into the iPixType, I assume the range of these
"unsigned short" values is mapped or cast into a range of "float" values.
Is the new range of values from 0.0 to 1.0, is that correct for the "float"
pixel type in ITK?  How does the ITK image reader convert or cast the pixel
values to float?  (The reason the input images are specified as "float"
rather than "unsigned short" is to have them input to the registration
method as floats - should this be done with an explicit cast filter?)

The input images have a black background (RGB value: 0 0 0).  It would be
great to threshold the MeanSquaresImageToImageMetric to exclude all the
black pixels.  In the range of values for the input pixel data that are an
unsigned short (0 to 65535), any pixel above 0 would be

unsigned short intensityThreshold = 1;

However, the intensityThreshold is declared and initialized as:

iBWImgType::PixelType intensityThreshold = 0.0;

Is this a reasonable value for this float intensityThreshold:

iBWImgType::PixelType intensityThreshold = 1.0 / USHRT_MAX;


TIA,
Darren




On Sat, Mar 6, 2010 at 12:15 PM, Luis Ibanez <luis.ibanez at kitware.com>wrote:

> Hi Darren,
>
> The feature that you are referring to, is only available
> in the new version of the metrics that are in the
> Code/Review directory.
>
> In order to use this classes you must reconfigure your
> binary build of ITK, by rerunning CMake and turning
> ON the CMake variables:
>
>   *  ITK_USE_REVIEW
>   *  OPTIMIZED_REGISTRATION_METHODS
>
> Then you can rebuild your application.
>
>
>     Regards,
>
>
>            Luis
>
>
>
> -----------------------------------------------------------------------------------
> On Thu, Mar 4, 2010 at 5:56 PM, Darren Weber
> <darren.weber.lists at gmail.com> wrote:
> >
> > In an image registration framework, the metric determines image
> "matches".
> > Let's suppose we have large images that contain a majority of background
> > color (or transparency).  In a metric like the
> > itk::MeanSquaresImageToImageMetric, the majority of the
> sqaured-diff-values
> > would be zero and the remainder of the "relevant" pixel differences may
> be
> > "swamped" or "lost" in the division by a large N.
> > Also, it appears the default metric sampling is a random-sample of the
> image
> > pixels (this might be modified with methods like
> "SetUseAllPixels(bool)").
> >  In this case, it is possible, perhaps likely, that few of the "relevant"
> > pixels will be evaluated in the metric.
> > See:
> >
> http://www.itk.org/Doxygen316/html/classitk_1_1ImageToImageMetric.html#42b876134388099afbf34b14faf83cdb
> > This documentation suggests there are also options to define:
> > IntensityThreshold, Masks, and SequentialSampling
> > In my reading of the doxy page (see next link), there is a method called
> > "SetFixedImageSamplesIntensityThreshold" that might be useful to define a
> > background value (like zero) to be excluded from the metric.  Is that
> right?
> >
> http://www.itk.org/Doxygen316/html/classitk_1_1MeanSquaresImageToImageMetric-members.html
> > What is the logic of this "threshold" method?  From the documentation, it
> > appears to be a minima value.  So if the background intensity is zero,
> the
> > threshold value of 1 would include all pixels > 0 (note the threshold
> value
> > must be the same type as the fixed image PixelType).
> > There is no equivalent method for the moving image,
> > like "SetMovingImageSamplesIntensityThreshold".  Is this unnecessary
> because
> > the metric only scans the pixels of the moving image that fall within the
> > "domain" of fixed image after the transform & interpolation?
> > I could not locate this method in the class hierarchy - is it available
> > (inherited) in all metrics?
> > I'm confused because these methods do not appear to be available
> > to itk::MeanSquaresImageToImageMetric
> > e.g.:  CODE:
> >     typedef itk::MeanSquaresImageToImageMetric< iBWImgType, iBWImgType >
> > MetricType;
> >     MetricType::Pointer metric = MetricType::New();
> >     metric->SetFixedImageSamplesIntensityThreshold( 0.0 );
> >     metric->SetUseAllPixels( true );
> > e.g.:  COMPILATION:
> > itkImageRigid2DCoregistration.cxx: In function ‘int main(int, char**)’:
> > itkImageRigid2DCoregistration.cxx:442: error: ‘class
> > itk::MeanSquaresImageToImageMetric<iBWImgType, iBWImgType>’ has no member
> > named ‘SetFixedImageSamplesIntensityThreshold’
> > itkImageRigid2DCoregistration.cxx:443: error: ‘class
> > itk::MeanSquaresImageToImageMetric<iBWImgType, iBWImgType>’ has no member
> > named ‘SetUseAllPixels’
> > gmake[2]: ***
> >
> [CMakeFiles/itkImageRigid2DCoregistration.dir/itkImageRigid2DCoregistration.cxx.o]
> > Error 1
> >
> >
> >
> > TIA,
> > Darren
> >
> > _____________________________________
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at
> > http://www.kitware.com/opensource/opensource.html
> >
> > Kitware offers ITK Training Courses, for more information visit:
> > http://www.kitware.com/products/protraining.html
> >
> > Please keep messages on-topic and check the ITK FAQ at:
> > http://www.itk.org/Wiki/ITK_FAQ
> >
> > Follow this link to subscribe/unsubscribe:
> > http://www.itk.org/mailman/listinfo/insight-users
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100315/bf57012a/attachment-0001.htm>
-------------- next part --------------
Image: testdata/bw/section0003_w1.tif
  Format: TIFF (Tagged Image File Format)
  Class: DirectClass
  Geometry: 549x539+0+0
  Resolution: 150x150
  Print size: 3.66x3.59333
  Units: PixelsPerInch
  Type: Grayscale
  Base type: Grayscale
  Endianess: MSB
  Colorspace: RGB
  Depth: 16-bit
  Channel depth:
    gray: 16-bit
  Channel statistics:
    Gray:
      min: 0 (0)
      max: 50725 (0.774014)
      mean: 30732.4 (0.468946)
      standard deviation: 16998.9 (0.259386)
      kurtosis: -0.493365
      skewness: -1.0826
  Rendering intent: Undefined
  Interlace: None
  Background color: white
  Border color: rgb(223,223,223)
  Matte color: grey74
  Transparent color: black
  Compose: Over
  Page geometry: 549x539+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: None
  Orientation: TopLeft
  Properties:
    date:create: 2010-03-05T14:00:07-08:00
    date:modify: 2010-03-05T14:00:07-08:00
    dc:format: image/tiff
    exif:ColorSpace: 1
    exif:NativeDigest: 36864,40960,40961,37121,37122,40962,40963,37510,40964,36867,36868,33434,33437,34850,34852,34855,34856,37377,37378,37379,37380,37381,37382,37383,37384,37385,37386,37396,41483,41484,41486,41487,41488,41492,41493,41495,41728,41729,41730,41985,41986,41987,41988,41989,41990,41991,41992,41993,41994,41995,41996,42016,0,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,20,22,23,24,25,26,27,28,30;9E964EF9C76A502891B383000F253C18
    exif:PixelXDimension: 549
    exif:PixelYDimension: 539
    photoshop:ColorMode: 3
    photoshop:History: Play action “section_selectWorm” of set “dweber”	

    photoshop:ICCProfile: sRGB IEC61966-2.1
    signature: 9001d6445177c62ec73647e4e4c01ba46ae637cd72d39623ee222d904b2601cd
    stRef:documentID: xmp.did:0780117407206811AE93BA7C6B531079
    stRef:instanceID: xmp.iid:07801174072068119109C955D2D011D9
    stRef:originalDocumentID: xmp.did:0780117407206811AE93BA7C6B531079
    tiff:Compression: 1
    tiff:document: /Volumes/data/plastic_imgproc/n2_20d/w1/bw/section0003_w1.tif
    tiff:ImageLength: 539
    tiff:ImageWidth: 549
    tiff:NativeDigest: 256,257,258,259,262,274,277,284,530,531,282,283,296,301,318,319,529,532,306,270,271,272,305,315,33432;56F9CD4C22FD05C82A003E42CDE60788
    tiff:photometric: min-is-black
    tiff:PhotometricInterpretation: 2
    tiff:PlanarConfiguration: 1
    tiff:rows-per-strip: 7
    tiff:SamplesPerPixel: 3
    tiff:software: ImageMagick 6.5.9-9 2010-02-22 Q16 http://www.imagemagick.org
    tiff:timestamp: 2010:03:04 15:05:00
    xmp:CreateDate: 2009-12-17T13:01:26-08:00
    xmp:CreatorTool: Adobe Photoshop CS4 Macintosh
    xmp:MetadataDate: 2010-03-04T15:05-08:00
    xmp:ModifyDate: 2010-03-04T15:05-08:00
    xmpMM:DocumentID: xmp.did:0780117407206811AE93BA7C6B531079
    xmpMM:InstanceID: xmp.iid:08801174072068119109C955D2D011D9
    xmpMM:OriginalDocumentID: xmp.did:0780117407206811AE93BA7C6B531079
  Profiles:
    Profile-8bim: 1462 bytes
    Profile-icc: 3144 bytes
      IEC 61966-2.1 Default RGB colour space - sRGB
    Profile-iptc: 8 bytes
      unknown[2,0]: 
    Profile-xmp: 17806 bytes
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 615KB
  Number pixels: 296KB
  Pixels per second: 29.59MB
  User time: 0.010u
  Elapsed time: 0:01.010
  Version: ImageMagick 6.5.9-9 2010-02-22 Q16 http://www.imagemagick.org


More information about the Insight-users mailing list