Browse Source

Adding missing properties

Former-commit-id: 2bcb2736710de731d8140623bf730b54b953b4fd
pull/17/head
James South 12 years ago
parent
commit
50d830cb03
  1. 28
      src/Plugins/ImageProcessor/ImageProcessor.Plugins.Cair/Imaging/ContentAwareResizeLayer.cs
  2. 18
      src/Plugins/ImageProcessor/ImageProcessor.Plugins.Cair/Processors/ContentAwareResize.cs
  3. 41
      src/Plugins/ImageProcessor/ImageProcessor.Plugins.Cair/Resources/Unmanaged/x86/Usage.txt

28
src/Plugins/ImageProcessor/ImageProcessor.Plugins.Cair/Imaging/ContentAwareResizeLayer.cs

@ -53,11 +53,6 @@ namespace ImageProcessor.Plugins.Cair.Imaging
this.Size = size;
}
/// <summary>
/// Gets or sets the size.
/// </summary>
public Size Size { get; set; }
/// <summary>
/// Gets or sets the content aware resize convolution type (Default ContentAwareResizeConvolutionType.Prewitt).
/// </summary>
@ -106,6 +101,23 @@ namespace ImageProcessor.Plugins.Cair.Imaging
}
}
/// <summary>
/// Gets or sets the size.
/// </summary>
public Size Size { get; set; }
/// <summary>
/// Gets or sets the the file path to a bitmap file that provides weight indicators specified using
/// color to guide preservation of image portions during carving.
/// <remarks>
/// The following colors define weight guidance.
/// &#10; <see cref="Color.Green"/> - Protect the weight.
/// &#10; <see cref="Color.Red"/> - Remove the weight.
/// &#10; <see cref="Color.Black"/> - No weight.
/// </remarks>
/// </summary>
public string WeightPath { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to assign multiple threads to the resizing method.
/// (Default true)
@ -165,7 +177,8 @@ namespace ImageProcessor.Plugins.Cair.Imaging
&& this.EnergyFunction == resizeLayer.EnergyFunction
&& this.OutputType == resizeLayer.OutputType
&& this.Parallelize == resizeLayer.Parallelize
&& this.Timeout == resizeLayer.Timeout;
&& this.Timeout == resizeLayer.Timeout
&& this.WeightPath == resizeLayer.WeightPath;
}
/// <summary>
@ -181,7 +194,8 @@ namespace ImageProcessor.Plugins.Cair.Imaging
this.EnergyFunction.GetHashCode() +
this.OutputType.GetHashCode() +
this.Parallelize.GetHashCode() +
this.Timeout.GetHashCode();
this.Timeout.GetHashCode() +
this.WeightPath.GetHashCode();
}
}
}

18
src/Plugins/ImageProcessor/ImageProcessor.Plugins.Cair/Processors/ContentAwareResize.cs

@ -19,7 +19,6 @@ namespace ImageProcessor.Plugins.Cair.Processors
using System.IO;
using ImageProcessor.Common.Exceptions;
using ImageProcessor.Imaging;
using ImageProcessor.Plugins.Cair.Imaging;
using ImageProcessor.Processors;
@ -76,9 +75,6 @@ namespace ImageProcessor.Plugins.Cair.Processors
ContentAwareResizeLayer layer = (ContentAwareResizeLayer)this.DynamicParameter;
int width = layer.Size.Width;
int height = layer.Size.Height;
ConvolutionType convolutionType = layer.ConvolutionType;
EnergyFunction energyFunction = layer.EnergyFunction;
bool parallelize = layer.Parallelize;
int timeout = layer.Timeout > 0 ? layer.Timeout : 60000;
int defaultMaxWidth;
@ -120,14 +116,20 @@ namespace ImageProcessor.Plugins.Cair.Processors
// Process the image using the CAIR executable.
string arguments = string.Format(
" -I \"{0}\" -O \"{1}\" -C {2} -X {3} -Y {4} -E {5} -T {6}",
" -I \"{0}\" -O \"{1}\" -C {2} -X {3} -Y {4} -E {5} -T {6} -R {7}",
sourcePath,
resizedPath,
(int)convolutionType,
(int)layer.ConvolutionType,
width,
height,
(int)energyFunction,
parallelize ? Math.Min(4, Environment.ProcessorCount) : 1);
(int)layer.EnergyFunction,
layer.Parallelize ? Math.Min(4, Environment.ProcessorCount) : 1,
(int)layer.OutputType);
if (!string.IsNullOrWhiteSpace(layer.WeightPath))
{
arguments = string.Format("{0} -W {1}", arguments, layer.WeightPath);
}
bool success = this.ProcessCairImage(arguments, timeout);

41
src/Plugins/ImageProcessor/ImageProcessor.Plugins.Cair/Resources/Unmanaged/x86/Usage.txt

@ -0,0 +1,41 @@
CAIR CLI Usage:
cair -I <input_file>
Other options:
-O <output_file>
Default: Dependent on operation
-W <weight_file>
Bitmap with: Black- no weight
Green- Protect weight
Red- Remove weight
Default: Weights are all zero
-S <weight_scale>
Default: 100,000
-X <goal_x>
Default: Source image width
-Y <goal_y>
Default: Source image height
-R <expected_result>
CAIR: 0
Grayscale: 1
Edge: 2
Vertical Energy: 3
Horizontal Energy: 4
Removal: 5
CAIR_HD: 6
Default: CAIR
-C <convoluton_type>
Prewitt: 0
V1: 1
V_SQUARE: 2
Sobel: 3
Laplacian: 4
Default: Prewitt
-E <energy_type>
Backward: 0
Forward: 1
Default: Backward
-T <thread_count>
Default : CAIR_NUM_THREADS (4)
Loading…
Cancel
Save