The StatisticsInformation Method is available in LEADTOOLS Document and Medical Imaging toolkits.
Returns statistical information about the image.
Syntax
Example
Visual Basic | Copy Code |
---|
Public Sub StatisticsInformationExample()
Dim client As ImageProcessingServiceClient = New ImageProcessingServiceClient()
Dim imageService As IImageProcessingService = TryCast(client, IImageProcessingService)
Dim sourceBinaryData As RawBinaryData = New RawBinaryData()
sourceBinaryData.Data = File.ReadAllBytes(Path.Combine(LEAD_VARS.ImagesDir, "image1.cmp"))
Dim convertOptions As RasterConvertOptions = New RasterConvertOptions()
convertOptions.Source = sourceBinaryData
convertOptions.Destination = Nothing
convertOptions.Format = RasterImageFormat.Bmp
convertOptions.FirstPage = 1
convertOptions.LastPage = 1
convertOptions.BitsPerPixel = 24
convertOptions.QualityFactor = 2
Dim request As StatisticsInformationRequest = New StatisticsInformationRequest()
request.ConvertOptions = convertOptions
request.Channel = RasterColorChannel.Master
request.Start = 0
request.End = 255
Dim response As StatisticsInformationResponse = imageService.StatisticsInformation(request)
Console.WriteLine(String.Format("Minimum = : {0}", response.Minimum))
Console.WriteLine(String.Format("Maximum = {0}", response.Maximum))
Console.WriteLine(String.Format("Mean = {0}", response.Mean))
Console.WriteLine(String.Format("Median = {0}", response.Median))
Console.WriteLine(String.Format("Percent = {0}", response.Percent))
Console.WriteLine(String.Format("StandardDeviation = {0}", response.StandardDeviation))
Console.WriteLine(String.Format("TotalPixelCount = {0}", response.TotalPixelCount))
client.Close()
End Sub
Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class |
C# | Copy Code |
---|
public void StatisticsInformationExample()
{
ImageProcessingServiceClient client = new ImageProcessingServiceClient();
IImageProcessingService imageService = client as IImageProcessingService;
RawBinaryData sourceBinaryData = new RawBinaryData();
sourceBinaryData.Data = File.ReadAllBytes(Path.Combine(LEAD_VARS.ImagesDir, "image1.cmp"));
RasterConvertOptions convertOptions = new RasterConvertOptions();
convertOptions.Source = sourceBinaryData;
convertOptions.Destination = null;
convertOptions.Format = RasterImageFormat.Bmp;
convertOptions.FirstPage = 1;
convertOptions.LastPage = 1;
convertOptions.BitsPerPixel = 24;
convertOptions.QualityFactor = 2;
StatisticsInformationRequest request = new StatisticsInformationRequest();
request.ConvertOptions = convertOptions;
request.Channel = RasterColorChannel.Master;
request.Start = 0;
request.End = 255;
StatisticsInformationResponse response = imageService.StatisticsInformation(request);
Console.WriteLine(string.Format("Minimum = : {0}", response.Minimum));
Console.WriteLine(string.Format("Maximum = {0}", response.Maximum));
Console.WriteLine(string.Format("Mean = {0}", response.Mean));
Console.WriteLine(string.Format("Median = {0}", response.Median));
Console.WriteLine(string.Format("Percent = {0}", response.Percent));
Console.WriteLine(string.Format("StandardDeviation = {0}", response.StandardDeviation));
Console.WriteLine(string.Format("TotalPixelCount = {0}", response.TotalPixelCount));
client.Close();
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
} |
Remarks
Requirements
Target Platforms: Microsoft .NET Framework 3.0, Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7
See Also