VintaSoft Imaging .NET SDK v8.7
Vintasoft.Imaging.ImageProcessing.Info Namespace / GetHistogramCommand Class
Members Example



In This Topic
    GetHistogramCommand Class
    In This Topic
    Gets an information about the histogram of the image.
    Object Model
    GetHistogramCommand ClassProcessingCommandResults ClassProcessingCommandResult Class
    Syntax
    'Declaration
     
    Public Class GetHistogramCommand 
       Inherits Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase
    public class GetHistogramCommand : Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase 
    public __gc class GetHistogramCommand : public Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase 
    public ref class GetHistogramCommand : public Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase 
    Example
    This example shows how to load an image from disk and calculate histogram of the image.
    Class GetHistogramCommandExample
    	Public Sub ProcessImage()
    		' [ do not forget to set your image file path here! ]
    		' open an existing image
    		Dim image As New Vintasoft.Imaging.VintasoftImage("Deskew.tif")
                
    		' create the command
    		Dim command As New Vintasoft.Imaging.ImageProcessing.Info.GetHistogramCommand()
    		command.HistogramType = Vintasoft.Imaging.ImageProcessing.HistogramType.Luminosity
                
    		Try
    			' execute the command
    			command.ExecuteInPlace(image)
    		Catch ex As Vintasoft.Imaging.ImageProcessing.ImageProcessingException
    			' show error message if problem occured
    			System.Windows.Forms.MessageBox.Show(ex.Message)
    			Return
    		End Try
                
    		Dim luminosityHistogram As Integer() = command.LuminosityHistogram
    		Dim luminosityHistogramString As String = String.Empty
                
    		For i As Integer = 0 To luminosityHistogram.Length - 2
    			luminosityHistogramString += String.Format("{0} ", luminosityHistogram(i))
    		Next
    		luminosityHistogramString += String.Format("{0}", luminosityHistogram(luminosityHistogram.Length - 1))
                
    		System.Windows.Forms.MessageBox.Show(String.Format("Luminosity histogram: {0}.", luminosityHistogramString))
    	End Sub
    End Class
    class GetHistogramCommandExample
    {
        public void ProcessImage()
        {
            // [ do not forget to set your image file path here! ]
            // open an existing image
            Vintasoft.Imaging.VintasoftImage image = new Vintasoft.Imaging.VintasoftImage("Deskew.tif");
                
            // create the command
            Vintasoft.Imaging.ImageProcessing.Info.GetHistogramCommand command =
                new Vintasoft.Imaging.ImageProcessing.Info.GetHistogramCommand();
            command.HistogramType = Vintasoft.Imaging.ImageProcessing.HistogramType.Luminosity;
                
            try
            {
                // execute the command
                command.ExecuteInPlace(image);
            }
            catch (Vintasoft.Imaging.ImageProcessing.ImageProcessingException ex)
            {
                // show error message if problem occured
                System.Windows.Forms.MessageBox.Show(ex.Message);
                return;
            }
                
            int[] luminosityHistogram = command.LuminosityHistogram;
            string luminosityHistogramString = string.Empty;
                
            for (int i = 0; i < luminosityHistogram.Length - 1; i++)
                luminosityHistogramString += string.Format("{0} ", luminosityHistogram[i]);
            luminosityHistogramString += string.Format("{0}", luminosityHistogram[luminosityHistogram.Length - 1]);
                
            System.Windows.Forms.MessageBox.Show(string.Format("Luminosity histogram: {0}.", luminosityHistogramString));
        }
    }
    Inheritance Hierarchy

    System.Object
       Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase
          Vintasoft.Imaging.ImageProcessing.Info.GetHistogramCommand

    Requirements

    Target Platforms: Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

    See Also