←Select platform

ReferenceForeground Property

Summary

A RasterColor object specifying the foreground color of the reference image.

Syntax
C#
Objective-C
C++/CLI
Java
Python
public RasterColor ReferenceForeground {get; set;} 
@property (nonatomic, assign) LTRasterColor* referenceForeground; 
public RasterColor getReferenceForeground(); 
public void setReferenceForeground( 
   RasterColor rasterColor 
); 
public:  
   property RasterColor^ ReferenceForeground 
   { 
      RasterColor^ get() 
      void set(RasterColor^ value) 
   } 
ReferenceForeground # get and set (CompareBitmapCommand) 

Property Value

The color used to identify the foreground content within the reference image. Typically, the foreground color is used to identify text. The default value is RasterColor.Black.

Example
C#
Java
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Core; 
 
public void CompareBitmapCommandExample() 
{ 
   using (RasterCodecs codecs = new RasterCodecs()) 
   // Load the original image 
   using (RasterImage referenceImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "ocr1.tif"))) 
   // Use the same image for the "modified" image 
   using (RasterImage modifiedImage = referenceImage.Clone()) 
   { 
      // Remove the last paragraph of the reference image 
      referenceImage.AddRectangleToRegion(null, new LeadRect(290, 2470, 1930, 360), RasterRegionCombineMode.Set); 
      new FillCommand(RasterColor.White).Run(referenceImage); 
      referenceImage.MakeRegionEmpty(); 
 
      // Remove the title from the modified image 
      modifiedImage.AddRectangleToRegion(null, new LeadRect(290, 300, 810, 110), RasterRegionCombineMode.Set); 
      new FillCommand(RasterColor.White).Run(modifiedImage); 
      modifiedImage.MakeRegionEmpty(); 
 
      // Rotate the modified image for demonstration (angle measured in hundredths of a degree) 
      new RotateCommand(340 * 100, RotateCommandFlags.Resize, RasterColor.Black).Run(modifiedImage); 
 
      // Update the transformation to align/reverse the above rotation 
      LeadMatrix alignment = LeadMatrix.Identity; 
      alignment.Translate(-modifiedImage.Width * 0.5, -modifiedImage.Height * 0.5); 
      alignment.Rotate(20.0); 
      alignment.Translate(referenceImage.Width * 0.5, referenceImage.Height * 0.5); 
 
      // Setup the comparison options 
      CompareBitmapCommand command = new CompareBitmapCommand() 
      { 
         Alignment = alignment, 
         ReferenceImage = referenceImage, 
         // following properties can be left to their defaults or set to desired values: 
         ModifiedBackground = RasterColor.White, 
         ModifiedForeground = RasterColor.Black, 
         OutputAddition = RasterColor.FromKnownColor(RasterKnownColor.Lime), 
         OutputBackground = RasterColor.FromKnownColor(RasterKnownColor.White), 
         OutputChange = RasterColor.FromKnownColor(RasterKnownColor.Yellow), 
         OutputDeletion = RasterColor.FromKnownColor(RasterKnownColor.Red), 
         OutputExternal = new RasterColor(0x80, 0x80, 0xff), 
         OutputMatch = new RasterColor(0x40, 0x40, 0x40), 
         ReferenceBackground = RasterColor.White, 
         ReferenceForeground = RasterColor.Black, 
         Threshold = 0 
      }; 
      // Compare the images 
      command.Run(modifiedImage); 
 
      // Save the results 
      using (RasterImage outputImage = command.OutputImage) 
         codecs.Save(outputImage, Path.Combine(LEAD_VARS.ImagesDir, "CompareBitmap_Output.png"), RasterImageFormat.Png, 0); 
 
      // Save the two input images, for reference 
      codecs.Save(referenceImage, Path.Combine(LEAD_VARS.ImagesDir, "CompareBitmap_Reference.png"), RasterImageFormat.Png, 0); 
      codecs.Save(modifiedImage, Path.Combine(LEAD_VARS.ImagesDir, "CompareBitmap_Modified.png"), RasterImageFormat.Png, 0); 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
 
import static org.junit.Assert.assertTrue; 
 
import java.io.File; 
import java.io.IOException; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
 
import leadtools.*; 
import leadtools.codecs.*; 
import leadtools.imageprocessing.FillCommand; 
import leadtools.imageprocessing.RotateCommand; 
import leadtools.imageprocessing.RotateCommandFlags; 
import leadtools.imageprocessing.core.CompareBitmapCommand; 
 
 
public void compareBitmapCommandExample() { 
 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
 
   RasterCodecs codecs = new RasterCodecs(); 
 
   // Load the original image 
   RasterImage referenceImage = codecs.load(combine(LEAD_VARS_IMAGES_DIR, "ocr1.tif")); 
 
   // Use the same image for the "modified" image 
   RasterImage modifiedImage = referenceImage.clone(); 
 
   // Remove the last paragraph of the reference image 
   referenceImage.addRectangleToRegion(null, new LeadRect(290, 2470, 1930, 360), RasterRegionCombineMode.SET); 
   new FillCommand(RasterColor.WHITE).run(referenceImage); 
   referenceImage.makeRegionEmpty(); 
 
   // Remove the title from the modified image 
   modifiedImage.addRectangleToRegion(null, new LeadRect(290, 300, 810, 110), RasterRegionCombineMode.SET); 
   new FillCommand(RasterColor.WHITE).run(modifiedImage); 
   modifiedImage.makeRegionEmpty(); 
 
   // Rotate the modified image for demonstration (angle measured in hundredths of 
   // a degree) 
   new RotateCommand(340 * 100, RotateCommandFlags.RESIZE.getValue(), RasterColor.BLACK).run(modifiedImage); 
 
   // Update the transformation to align/reverse the above rotation 
   LeadMatrix alignment = LeadMatrix.getIdentity(); 
   alignment.translate(-1 * modifiedImage.getWidth() * 0.5, -1 * modifiedImage.getHeight() * 0.5); 
   alignment.rotate(20.0); 
   alignment.translate(referenceImage.getWidth() * 0.5, referenceImage.getHeight() * 0.5); 
 
   // Setup the comparison options 
   CompareBitmapCommand command = new CompareBitmapCommand(); 
   command.setAlignment(alignment); 
   command.setReferenceImage(referenceImage); 
 
   // Compare the images 
   command.run(modifiedImage); 
 
   // Save the results 
   RasterImage outputImage = command.getOutputImage(); 
   codecs.save(outputImage, combine(LEAD_VARS_IMAGES_DIR, "CompareBitmap_Output.png"), RasterImageFormat.PNG, 0); 
 
   // Save the two input images, for reference 
   codecs.save(referenceImage, combine(LEAD_VARS_IMAGES_DIR, "CompareBitmap_Reference.png"), RasterImageFormat.PNG, 
         0); 
   codecs.save(modifiedImage, combine(LEAD_VARS_IMAGES_DIR, "CompareBitmap_Modified.png"), RasterImageFormat.PNG, 0); 
   referenceImage.dispose(); 
   codecs.dispose(); 
 
   assertTrue(new File(combine(LEAD_VARS_IMAGES_DIR, "CompareBitmap_Reference.png")).exists()); 
   System.out.println("Command run, image saved to " + combine(LEAD_VARS_IMAGES_DIR, "CompareBitmap_Reference.png")); 
} 
Requirements

Target Platforms

Help Version 23.0.2024.3.3
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.ImageProcessing.Core Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.