VintaSoft Imaging .NET SDK v8.6
Vintasoft.Imaging.ImageProcessing.Info Namespace / GetUniqueColorCommand Class
Members Example



In This Topic
    GetUniqueColorCommand Class
    In This Topic
    Determines the color of image rectangular region if image region contains only one color.
    Object Model
    GetUniqueColorCommand ClassColorBase ClassRegionOfInterest ClassProcessingCommandResults ClassProcessingCommandResult Class
    Syntax
    'Declaration
     
    Public Class GetUniqueColorCommand 
       Inherits Vintasoft.Imaging.ImageProcessing.ProcessingCommandWithRegion
    public __gc class GetUniqueColorCommand : public Vintasoft.Imaging.ImageProcessing.ProcessingCommandWithRegion 
    public ref class GetUniqueColorCommand : public Vintasoft.Imaging.ImageProcessing.ProcessingCommandWithRegion 
    Example
    This example shows how to load an image from disk and calculate the unique color in the image.
    Class GetUniqueColorCommandExample
        Public Sub ProcessImage()
            ' open an image from file
            Dim image As New Vintasoft.Imaging.VintasoftImage("Deskew.tif")
                
            ' create the command
            Dim command As New Vintasoft.Imaging.ImageProcessing.Info.GetUniqueColorCommand()
                
            Try
                ' execute the command
                command.ExecuteInPlace(image)
            Catch ex As Vintasoft.Imaging.ImageProcessing.ImageProcessingException
                ' show error message if error occured
                System.Windows.Forms.MessageBox.Show(ex.Message)
                Return
            End Try
                
            ' show result
            If command.IsColorDetected Then
                System.Windows.Forms.MessageBox.Show(String.Format("Image has unique color {0}.", command.Color))
            Else
                System.Windows.Forms.MessageBox.Show("Image does not have unique color.")
            End If
        End Sub
    End Class
    class GetUniqueColorCommandExample
    {
        public void ProcessImage()
        {
            // open an image from file
            Vintasoft.Imaging.VintasoftImage image = new Vintasoft.Imaging.VintasoftImage("Deskew.tif");
                
            // create the command
            Vintasoft.Imaging.ImageProcessing.Info.GetUniqueColorCommand command =
                new Vintasoft.Imaging.ImageProcessing.Info.GetUniqueColorCommand();
                
            try
            {
                // execute the command
                command.ExecuteInPlace(image);
            }
            catch (Vintasoft.Imaging.ImageProcessing.ImageProcessingException ex)
            {
                // show error message if error occured
                System.Windows.Forms.MessageBox.Show(ex.Message);
                return;
            }
                
            // show result
            if (command.IsColorDetected)
            {
                System.Windows.Forms.MessageBox.Show(string.Format("Image has unique color {0}.", command.Color));
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Image does not have unique color.");
            }
        }
    }
    Inheritance Hierarchy

    System.Object
       Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase
          Vintasoft.Imaging.ImageProcessing.ProcessingCommandWithRegion
             Vintasoft.Imaging.ImageProcessing.Info.GetUniqueColorCommand

    Requirements

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

    See Also