Utilities/IpSegmentation/ipSegmentationInterpolate.c
mitkIpPicDescriptor*
ipMITKSegmentationShrinkBy1Pixel (mitkIpPicDescriptor* pic_in )
{
  mitkIpPicDescriptor* pic_out;
  ipMITKSegmentationTYPE* out_pixel_pointer;
  ipMITKSegmentationTYPE* in_pixel_pointer;
  unsigned int x, y;

  //prepare the images
  pic_out = mitkIpPicCopyHeader(pic_in, NULL);
  if (pic_out == NULL) {
      ipMITKSegmentationError (ipMITKSegmentationPIC_NULL);
  }

  if ((pic_out->type != ipMITKSegmentationTYPE_ID) || (pic_out->bpe != ipMITKSegmentationBPE))
  {
    ipMITKSegmentationError (ipMITKSegmentationWRONG_TYPE);
  }

  // pad by 1 pixel
  pic_out->n[0] -= 4;
  pic_out->n[1] -= 4;

  // allocate image data
  pic_out->data = malloc ( pic_out->n[0] * pic_out->n[1] * (pic_out->bpe/8) );

  // copy pixel data
  out_pixel_pointer = pic_out->data;
  in_pixel_pointer = pic_in->data;

  for (y = 0; y < pic_in->n[1]; ++y)
    for (x = 0; x < pic_in->n[0]; ++x)
    {
      if ( x < 2  || y < 2 || (x > pic_in->n[0]-3) || (y > pic_in->n[1]-3) ) // ignore border pixels
      {
      }
      else
      {
        *out_pixel_pointer = *in_pixel_pointer;
        ++out_pixel_pointer;
      }
      ++in_pixel_pointer;
    }

  return pic_out;
}
// Works ONLY with 2D images.
Works ONLY with 2D images.
Works ONLY with 2D images .
mitkIpPicDescriptor*
ipMITKSegmentationShrinkBy1Pixel (mitkIpPicDescriptor* pic_in )
{
  mitkIpPicDescriptor* pic_out;
  ipMITKSegmentationTYPE* out_pixel_pointer;
  ipMITKSegmentationTYPE* in_pixel_pointer;
  unsigned int x, y;
  pic_out = mitkIpPicCopyHeader(pic_in, NULL);
  if (pic_out == NULL) {
      ipMITKSegmentationError (ipMITKSegmentationPIC_NULL);
  }
  if ((pic_out->type != ipMITKSegmentationTYPE_ID) || (pic_out->bpe != ipMITKSegmentationBPE))
  {
    ipMITKSegmentationError (ipMITKSegmentationWRONG_TYPE);
  }
  pic_out->n[0] -= 4;
  pic_out->n[1] -= 4;
  pic_out->data = malloc ( pic_out->n[0] * pic_out->n[1] * (pic_out->bpe/8) );
  out_pixel_pointer = pic_out->data;
  in_pixel_pointer = pic_in->data;
  for (y = 0; y < pic_in->n[1]; ++y)
    for (x = 0; x < pic_in->n[0]; ++x)
    {
      if ( x < 2  || y < 2 || (x > pic_in->n[0]-3) || (y > pic_in->n[1]-3) ) 
      {
      }
      else
      {
        *out_pixel_pointer = *in_pixel_pointer;
        ++out_pixel_pointer;
      }
      ++in_pixel_pointer;
    }
  return pic_out;
}
mitkIpPicDescriptor * ipMITKSegmentationShrinkBy1Pixel ( mitkIpPicDescriptor * pic_in ) { mitkIpPicDescriptor * pic_out ; ipMITKSegmentationTYPE * out_pixel_pointer ; ipMITKSegmentationTYPE * in_pixel_pointer ; unsigned int x , y ; pic_out = mitkIpPicCopyHeader ( pic_in , NULL ) ; if ( pic_out == NULL ) { ipMITKSegmentationError ( ipMITKSegmentationPIC_NULL ) ; } if ( ( pic_out -> type != ipMITKSegmentationTYPE_ID ) || ( pic_out -> bpe != ipMITKSegmentationBPE ) ) { ipMITKSegmentationError ( ipMITKSegmentationWRONG_TYPE ) ; } pic_out -> n [ 0 ] -= 4 ; pic_out -> n [ 1 ] -= 4 ; pic_out -> data = malloc ( pic_out -> n [ 0 ] * pic_out -> n [ 1 ] * ( pic_out -> bpe / 8 ) ) ; out_pixel_pointer = pic_out -> data ; in_pixel_pointer = pic_in -> data ; for ( y = 0 ; y < pic_in -> n [ 1 ] ; ++ y ) for ( x = 0 ; x < pic_in -> n [ 0 ] ; ++ x ) { if ( x < 2 || y < 2 || ( x > pic_in -> n [ 0 ] - 3 ) || ( y > pic_in -> n [ 1 ] - 3 ) ) { } else { * out_pixel_pointer = * in_pixel_pointer ; ++ out_pixel_pointer ; } ++ in_pixel_pointer ; } return pic_out ; }
Works ONLY with 2D images.
Works ONLY with 2D images .
//prepare the images // pad by 1 pixel // allocate image data // copy pixel data // ignore border pixels