←Select platform

BalanceColorsCommand Constructor(BalanceColorCommandFactor,BalanceColorCommandFactor,BalanceColorCommandFactor)

Summary
Initializes a new BalanceColorsCommand with explicit parameters.
Syntax
C#
Objective-C
C++/CLI
Java
Python
- (instancetype)initWithRedFactor:(LTBalanceColorCommandFactor *)redFactor greenFactor:(LTBalanceColorCommandFactor *)greenFactor blueFactor:(LTBalanceColorCommandFactor *)blueFactor NS_DESIGNATED_INITIALIZER; 
__init__(self,redFactor,greenFactor,blueFactor) # Overloaded constructor 

Parameters

redFactor
BalanceColorCommandFactor class that contains the values to use for redistributing the image's red values. Valid values for all class members must be within the range : 0.0 - 100.0.

greenFactor
BalanceColorCommandFactor class that contains the values to use for redistributing the image's green values. Valid values for all class members must be within the range : 0.0 - 100.0.

blueFactor
BalanceColorCommandFactor class that contains the values to use for redistributing the image's blue values. Valid values for all class members must be within the range : 0.0 - 100.0.

Example

Run the BalanceColorsCommand on an image.

C#
Java
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing.Color; 
 
 
public void BalanceColorsConstructorExample() 
{ 
   // Load an image 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.ThrowExceptionsOnInvalidImages = true; 
 
   RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, @"ImageProcessingDemo\Image2.jpg")); 
 
   // Prepare the command 
   BalanceColorCommandFactor RedFactor = new BalanceColorCommandFactor(); 
   BalanceColorCommandFactor GreenFactor = new BalanceColorCommandFactor(); 
   BalanceColorCommandFactor BlueFactor = new BalanceColorCommandFactor(); 
 
   RedFactor.ToRed = 0.2; 
   RedFactor.ToGreen = 0.3; 
   RedFactor.ToBlue = 0.5; 
 
   GreenFactor.ToRed = 0.3; 
   GreenFactor.ToGreen = 0.1; 
   GreenFactor.ToBlue = 0.6; 
 
   BlueFactor.ToRed = 0.8; 
   BlueFactor.ToGreen = 0.1; 
   BlueFactor.ToBlue = 0.1; 
 
   BalanceColorsCommand command = new BalanceColorsCommand(RedFactor, GreenFactor, BlueFactor); 
   command.Run(image); 
   codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "Result.jpg"), RasterImageFormat.Jpeg, 24); 
 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
 
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 static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.codecs.*; 
import leadtools.imageprocessing.color.*; 
 
 
public void balanceColorsConstructorExample() { 
 
   String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
   String outputFilePath = combine(LEAD_VARS_IMAGES_DIR, "Result.jpg"); 
 
   // Load and Image 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.setThrowExceptionsOnInvalidImages(true); 
 
   RasterImage image = codecs.load(combine(LEAD_VARS_IMAGES_DIR, "Image2.jpg")); 
 
   // Prepare the Command 
   BalanceColorCommandFactor redFactor = new BalanceColorCommandFactor(); 
   BalanceColorCommandFactor greenFactor = new BalanceColorCommandFactor(); 
   BalanceColorCommandFactor blueFactor = new BalanceColorCommandFactor(); 
 
   redFactor.setToRed(0.2); 
   redFactor.setToGreen(0.3); 
   redFactor.setToBlue(0.5); 
 
   greenFactor.setToRed(0.3); 
   greenFactor.setToGreen(0.1); 
   greenFactor.setToBlue(0.6); 
 
   blueFactor.setToRed(0.8); 
   blueFactor.setToGreen(0.1); 
   blueFactor.setToBlue(0.1); 
 
   BalanceColorsCommand command = new BalanceColorsCommand(redFactor, greenFactor, blueFactor); 
   command.run(image); 
   codecs.save(image, outputFilePath, RasterImageFormat.JPEG, 24); 
 
   assertTrue(new File(outputFilePath).exists()); 
   System.out.println("Command run and image saved to " + (outputFilePath)); 
 
} 
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.Color Assembly

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