예제 #1
0
 /// <summary>
 /// Constructs a new ImageStack32F
 /// </summary>
 /// <param name="width">The width of each slice</param>
 /// <param name="height">The height of each slice</param>
 /// <param name="nZ">The number of zPlanes</param>
 /// <param name="nT">The number of time-slices</param>
 /// <param name="sliceOrder">The ordering of the slices in the stack</param>
 public ImageStack32F(int width, int height, int nZ, int nT, ImageStack.SliceOrders sliceOrder)
 {
     if (width < 1)
         throw new ArgumentOutOfRangeException(nameof(width), "Has to be 1 or greater.");
     if (height < 1)
         throw new ArgumentOutOfRangeException(nameof(height), "Has to be 1 or greater.");
     if (nZ < 1)
         throw new ArgumentOutOfRangeException(nameof(nZ), "Has to be 1 or greater.");
     if (nT < 1)
         throw new ArgumentOutOfRangeException(nameof(nT), "Has to be 1 or greater.");
     SliceOrder = sliceOrder;
     InitializeImageBuffer(width, height, nZ, nT, 4);
 }
예제 #2
0
 /// <summary>
 /// Initialize image buffer according to another image
 /// and copy image data.
 /// </summary>
 /// <param name="imsource">The source image to copy</param>
 protected void InitializeAsCopy(ImageStack imsource)
 {
     DisposeGuard();
     _pixelSize  = imsource._pixelSize;
     SliceOrder  = imsource.SliceOrder;
     ImageWidth  = imsource.ImageWidth;
     ImageHeight = imsource.ImageHeight;
     ZPlanes     = imsource.ZPlanes;
     TimePoints  = imsource.TimePoints;
     Stride      = imsource.Stride;
     //request image buffer
     RequestImageData((IntPtr)(Stride * ImageHeight * ZPlanes * TimePoints));
     //copy actual data
     CopyImageMemory(imsource, this);
 }
예제 #3
0
 /// <summary>
 /// Directly copy memory from one image to another if their buffer size is the same
 /// No checks are performed to ensure that both ImageStacks have same layout, bit depth, etc.
 /// </summary>
 /// <param name="src">The source ImageStack</param>
 /// <param name="dst">The destination ImageStac, memory will be overwritten</param>
 protected static void CopyImageMemory(ImageStack src, ImageStack dst)
 {
     if (src.ImageNB != dst.ImageNB)
     {
         throw new ArgumentException("src and dst need to have the same memory size");
     }
     if (src._imageData == dst._imageData)
     {
         throw new ArgumentException("src and dst cannot point to the same buffer");
     }
     if (src._imageData == null || dst._imageData == null)
     {
         throw new ArgumentException("src and dst cannot have null pointers");
     }
     memcpy_s((IntPtr)dst._imageData, (UIntPtr)dst.ImageNB, (IntPtr)src._imageData, (UIntPtr)src.ImageNB);
 }
예제 #4
0
 /// <summary>
 /// Checks whether a given image stack has dimensions compatible
 /// with this image stack
 /// </summary>
 /// <param name="ims">The stack to compare</param>
 /// <returns>True if the given image is compatible</returns>
 public bool IsCompatible(ImageStack ims)
 {
     return((ims.SliceOrder == SliceOrder) & (ims.ImageWidth == ImageWidth) & (ims.ImageHeight == ImageHeight) & (ims.ZPlanes == ZPlanes) & (ims.TimePoints == TimePoints));
 }
예제 #5
0
 /// <summary>
 /// Checks whether a given image stack has dimensions compatible
 /// with this image stack
 /// </summary>
 /// <param name="ims">The stack to compare</param>
 /// <returns>True if the given image is compatible</returns>
 public bool IsCompatible(ImageStack ims)
 {
     return (ims.SliceOrder == SliceOrder) & (ims.ImageWidth == ImageWidth) & (ims.ImageHeight == ImageHeight) & (ims.ZPlanes == ZPlanes) & (ims.TimePoints == TimePoints);
 }
예제 #6
0
 /// <summary>
 /// Directly copy memory from one image to another if their buffer size is the same
 /// No checks are performed to ensure that both ImageStacks have same layout, bit depth, etc.
 /// </summary>
 /// <param name="src">The source ImageStack</param>
 /// <param name="dst">The destination ImageStac, memory will be overwritten</param>
 protected static void CopyImageMemory(ImageStack src, ImageStack dst)
 {
     if (src.ImageNB != dst.ImageNB)
         throw new ArgumentException("src and dst need to have the same memory size");
     if (src._imageData == dst._imageData)
         throw new ArgumentException("src and dst cannot point to the same buffer");
     if (src._imageData == null || dst._imageData == null)
         throw new ArgumentException("src and dst cannot have null pointers");
     memcpy_s((IntPtr)dst._imageData, (UIntPtr)dst.ImageNB, (IntPtr)src._imageData, (UIntPtr)src.ImageNB);
 }
예제 #7
0
 /// <summary>
 /// Initialize image buffer according to another image
 /// and copy image data.
 /// </summary>
 /// <param name="imsource">The source image to copy</param>
 protected void InitializeAsCopy(ImageStack imsource)
 {
     DisposeGuard();
     _pixelSize = imsource._pixelSize;
     SliceOrder = imsource.SliceOrder;
     ImageWidth = imsource.ImageWidth;
     ImageHeight = imsource.ImageHeight;
     ZPlanes = imsource.ZPlanes;
     TimePoints = imsource.TimePoints;
     Stride = imsource.Stride;
     //request image buffer
     RequestImageData((IntPtr)(Stride * ImageHeight * ZPlanes * TimePoints));
     //copy actual data
     CopyImageMemory(imsource, this);
 }