Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

Commit

Permalink
GH-654: Adding the Distance Transform algorithm.
Browse files Browse the repository at this point in the history
  • Loading branch information
cesarsouza committed Jun 23, 2017
1 parent 124044a commit 0808963
Show file tree
Hide file tree
Showing 10 changed files with 534 additions and 4 deletions.
31 changes: 31 additions & 0 deletions Sources/Accord.Imaging/AForge.Imaging/UnmanagedImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,20 @@ public class UnmanagedImage : IDisposable
{
// pointer to image data in unmanaged memory
private IntPtr imageData;

// image size
private int width, height;

// image stride (line size)
private int stride;

// image pixel format
private PixelFormat pixelFormat;

// flag which indicates if the image should be disposed or not
private bool mustBeDisposed = false;


/// <summary>
/// Pointer to image data in unmanaged memory.
/// </summary>
Expand Down Expand Up @@ -114,6 +119,15 @@ public PixelFormat PixelFormat
get { return pixelFormat; }
}

/// <summary>
/// Gets the image size, in bytes.
/// </summary>
///
public int Bytes
{
get { return stride * height; }
}

/// <summary>
/// Initializes a new instance of the <see cref="UnmanagedImage"/> class.
/// </summary>
Expand Down Expand Up @@ -1112,5 +1126,22 @@ public ushort[] Collect16bppPixelValues(List<IntPoint> points)

return pixelValues;
}

/// <summary>
/// Converts the image into a sequence of bytes.
/// </summary>
///
public byte[] ToByteArray()
{
byte[] bytes = new byte[Bytes];
unsafe
{
fixed (byte* dst = bytes)
{
Buffer.MemoryCopy(this.imageData.ToPointer(), dst, bytes.Length, bytes.Length);
}
}
return bytes;
}
}
}
1 change: 1 addition & 0 deletions Sources/Accord.Imaging/Accord.Imaging.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@
<Compile Include="AForge.Imaging\Filters\Normalized RGB\ExtractNormalizedRGBChannel.cs" />
<Compile Include="AForge.Imaging\Filters\Other\ApplyMask.cs" />
<Compile Include="Blob Processing\IBlobsFilter.cs" />
<Compile Include="Filters\DistanceTransform.cs" />
<Compile Include="Filters\Other\BlobsFiltering.cs" />
<Compile Include="AForge.Imaging\Filters\Other\CanvasCrop.cs" />
<Compile Include="AForge.Imaging\Filters\Other\CanvasFill.cs" />
Expand Down
Loading

0 comments on commit 0808963

Please sign in to comment.