Utilities/IpSegmentation/ipSegmentationInterpolate.c
mitkIpPicDescriptor*
ipMITKSegmentationPadBy1Pixel (mitkIpPicDescriptor* pic_in)
{
  //prepare the images
  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);
  }

  // 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 = (ipMITKSegmentationTYPE*) (pic_out->data);
  in_pixel_pointer = (ipMITKSegmentationTYPE*) (pic_in->data);

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

  return pic_out;
}
// Works ONLY with 2D images.
Works ONLY with 2D images.
Works ONLY with 2D images .
mitkIpPicDescriptor*
ipMITKSegmentationPadBy1Pixel (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 = (ipMITKSegmentationTYPE*) (pic_out->data);
  in_pixel_pointer = (ipMITKSegmentationTYPE*) (pic_in->data);
  for (y = 0; y < pic_out->n[1]; ++y)
    for (x = 0; x < pic_out->n[0]; ++x)
    {
      if ( x < 2  || y < 2 || (x > pic_out->n[0]-3) || (y > pic_out->n[1]-3) ) 
      {
        *out_pixel_pointer = 0;
      }
      else
      {
        *out_pixel_pointer = *in_pixel_pointer;
        ++in_pixel_pointer;
      }
      ++out_pixel_pointer;
    }
  return pic_out;
}
mitkIpPicDescriptor * ipMITKSegmentationPadBy1Pixel ( 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 = ( ipMITKSegmentationTYPE * ) ( pic_out -> data ) ; in_pixel_pointer = ( ipMITKSegmentationTYPE * ) ( pic_in -> data ) ; for ( y = 0 ; y < pic_out -> n [ 1 ] ; ++ y ) for ( x = 0 ; x < pic_out -> n [ 0 ] ; ++ x ) { if ( x < 2 || y < 2 || ( x > pic_out -> n [ 0 ] - 3 ) || ( y > pic_out -> n [ 1 ] - 3 ) ) { * out_pixel_pointer = 0 ; } else { * out_pixel_pointer = * in_pixel_pointer ; ++ in_pixel_pointer ; } ++ out_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 // set border pixels to 0