本文整理汇总了C#中IImage.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# IImage.Clone方法的具体用法?C# IImage.Clone怎么用?C# IImage.Clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IImage
的用法示例。
在下文中一共展示了IImage.Clone方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessImageAsync
public Task<IProcessServiceResult> ProcessImageAsync(string processorName, IImage image)
{
var result = new ImageProcessServiceResult();
var processor = _processors.FirstOrDefault(p => p.Name == processorName);
if (processor != null)
{
try
{
var imageForProcessing = image.Clone();
processor.ProcessImage(imageForProcessing);
result.ProcessedImage = imageForProcessing;
result.Successful = true;
}
catch (Exception e)
{
result.Successful = false;
result.ErrorMessage = e.Message;
}
}
else
{
result.Successful = false;
result.ErrorMessage = $"Can't find processor with name {processorName}";
}
return Task.FromResult((IProcessServiceResult)result);
}
示例2: ProcessImage
public void ProcessImage(IImage image)
{
var imageForProcessing = image.Clone();
_edgeFilter.ProcessImage(imageForProcessing);
var segments = _segmentationAlgorithm.ProcessImage(imageForProcessing);
IEnumerable<IFindResult> findResult = _segmentFindAnalyzer.Find(segments);
_findResultDrawer.DrawFindResults(image, findResult);
}
开发者ID:DashaVeresova,项目名称:RecognitionOfDrivingLicenses,代码行数:8,代码来源:SelectFounedAreaAfterSegmentationImageProcessor.cs
示例3: HandleFindResults
public void HandleFindResults(IImage image, IEnumerable<IFindResult> results)
{
foreach (var result in results)
{
var clone = image.Clone();
clone.Clip(result.Points, result.Angle);
var partFindResult = _findAlgoritm.Find(clone);
_findResultsHandler.HandleFindResults(clone, partFindResult);
}
}
示例4: HandleFindResults
public void HandleFindResults(IImage image, IEnumerable<IFindResult> results)
{
var findResults = results as IFindResult[] ?? results.ToArray();
foreach (var findResult in findResults)
{
var coppy = image.Clone();
coppy.Clip(findResult.Points, findResult.Angle);
_imageRepository.SaveImageAsync(coppy).Wait();
}
}
示例5: IdentifyAsync
public Task<IIdentifyResult> IdentifyAsync(IImage inputImage)
{
var result = new IdentifyResult();
var imageClone = inputImage.Clone();
var segments = _segmentationAlgoritm.ProcessImage(imageClone);
var selectedAreas = _segmentFindAnalyzer.Find(segments);
_findResultsHandler.HandleFindResults(inputImage, selectedAreas);
result.ProcessedImage = inputImage;
return Task.FromResult((IIdentifyResult)result);
}
示例6: ConverToGrayColors
public void ConverToGrayColors(IImage image)
{
var original = image.Clone();
for (int i = 0; i < original.Width; i++)
{
for (int j = 0; j < original.Height; j++)
{
var red = original.GetPixel(i, j).R;
var green = original.GetPixel(i, j).G;
var blue = original.GetPixel(i, j).B;
var pixelLum = (byte)(0.21 * red + 0.71 * green + 0.07 * blue);
image.SetPixel(i, j, new Pixel { R = pixelLum, G = pixelLum, B = pixelLum });
}
}
}
示例7: saveDebugImage
private void saveDebugImage(IImage image, string name)
{
if (isTraining)
return;
if (debugImages == null)
{
// if (!Directory.Exists(debugFolder))
// {
// Directory.CreateDirectory(debugFolder);
// }
// image.Save(debugFolder + name + ".png");
return;
}
DebugImage debugImage = new DebugImage();
debugImage.Image = (IImage)image.Clone();
debugImage.Name = name;
debugImages.Add(debugImage);
}
示例8: ProcessImage
public void ProcessImage(IImage image)
{
var imageClone = image.Clone();
IEnumerable<IFindResult> findResult = _findAlgoritm.Find(imageClone);
_findResultsHandler.HandleFindResults(image, findResult);
}
示例9: TransfromImageForwards
public MaskedImage TransfromImageForwards(IImage image, bool preserveSize = false)
{
MaskedImage undistorted;
var influences = FindInfluenceMatrix(image.RowCount, image.ColumnCount);
Matrix<double>[] matrices = new Matrix<double>[image.ChannelsCount];
if(preserveSize)
{
// New image is in old one's coords
undistorted = new MaskedImage(image.Clone());
for(int i = 0; i < image.ChannelsCount; ++i)
{
matrices[i] = new DenseMatrix(image.RowCount, image.ColumnCount);
undistorted.SetMatrix(matrices[i], i);
}
// Bound processing to smaller of images in each dimesions
int minX = Math.Max(0, _finalTopLeft.X);
int maxX = Math.Min(image.ColumnCount, _finalSize.X + _finalTopLeft.X);
int minY = Math.Max(0, _finalTopLeft.Y);
int maxY = Math.Min(image.RowCount, _finalSize.Y + _finalTopLeft.Y);
for(int x = minX; x < maxX; ++x)
{
for(int y = minY; y < maxY; ++y)
{
double influenceTotal = 0.0;
double[] val = new double[image.ChannelsCount];
foreach(var inf in influences[y - _finalTopLeft.Y, x - _finalTopLeft.X]) // Move Pu to influence matrix coords
{
for(int i = 0; i < image.ChannelsCount; ++i)
val[i] += image[inf.Yd, inf.Xd, i] * inf.Influence;
influenceTotal += inf.Influence;
}
if(influenceTotal > 0.25)
{
for(int i = 0; i < image.ChannelsCount; ++i)
matrices[i].At(y, x, val[i] / influenceTotal);
undistorted.SetMaskAt(y, x, true);
}
else
{
undistorted.SetMaskAt(y, x, false);
}
}
}
}
else
{
// New image is in same coords as influence matrix
for(int i = 0; i < image.ChannelsCount; ++i)
matrices[i] = new DenseMatrix(_finalSize.Y, _finalSize.X);
IImage img = image.Clone();
for(int i = 0; i < image.ChannelsCount; ++i)
img.SetMatrix(matrices[i], i);
undistorted = new MaskedImage(image.Clone());
for(int x = 0; x < _finalSize.X; ++x)
{
for(int y = 0; y < _finalSize.Y; ++y)
{
double influenceTotal = 0.0;
double[] val = new double[image.ChannelsCount];
foreach(var inf in influences[y, x])
{
for(int i = 0; i < image.ChannelsCount; ++i)
val[i] += image[inf.Yd, inf.Xd, i] * inf.Influence;
influenceTotal += inf.Influence;
}
if(influenceTotal > 0.5)
{
for(int i = 0; i < image.ChannelsCount; ++i)
matrices[i].At(y, x, val[i] / influenceTotal);
undistorted.SetMaskAt(y, x, true);
}
else
{
undistorted.SetMaskAt(y, x, false);
}
}
}
}
return undistorted;
}
示例10: TransfromImageBackwards
public MaskedImage TransfromImageBackwards(IImage image, bool preserveSize = false)
{
MaskedImage undistorted;
FindTransformedImageSize(image.RowCount, image.ColumnCount);
Matrix<double>[] matrices = new Matrix<double>[image.ChannelsCount];
if(preserveSize)
{
undistorted = new MaskedImage(image.Clone());
for(int i = 0; i < image.ChannelsCount; ++i)
{
matrices[i] = new DenseMatrix(image.RowCount, image.ColumnCount);
undistorted.SetMatrix(matrices[i], i);
}
}
else
{
IImage img = image.Clone();
for(int i = 0; i < image.ChannelsCount; ++i)
{
matrices[i] = new DenseMatrix(_finalSize.Y, _finalSize.X);
img.SetMatrix(matrices[i], i);
}
undistorted = new MaskedImage(image.Clone());
}
int R = InterpolationRadius;
int R21 = R * 2 + 1;
for(int x = 0; x < matrices[0].ColumnCount; ++x)
{
for(int y = 0; y < matrices[0].RowCount; ++y)
{
// Cast point from new image to old one
Vector2 oldCoords = Transformation.TransformPointBackwards(new Vector2(x: x, y: y));
Vector2 aa = Transformation.TransformPointForwards(oldCoords);
IntVector2 oldPixel = new IntVector2(oldCoords);
// Check if point is in old image range or points to undefined point
if(oldCoords.X < 0 || oldCoords.X > image.ColumnCount ||
oldCoords.Y < 0 || oldCoords.Y > image.RowCount ||
image.HaveValueAt(oldPixel.Y, oldPixel.X) == false)
{
// Point out of range, so set to black
for(int i = 0; i < image.ChannelsCount; ++i)
{
matrices[i].At(y, x, 0.0);
undistorted.SetMaskAt(y, x, false);
}
}
else
{
// Interpolate value from patch in old image
double[,] influence = new double[R21, R21];
double totalInf = 0;
// For each pixel in neighbourhood find its distance and influence of Pu on it
for(int dx = -R; dx <= R; ++dx)
{
for(int dy = -R; dy <= R; ++dy)
{
double distance = _computeDistance(oldCoords, oldPixel.X + dx, oldPixel.Y + dy);
influence[dx + R, dy + R] = 1.0 / distance;
totalInf += influence[dx + R, dy + R];
}
}
double infScale = 1.0 / totalInf; // Scale influence, so that its sum over all pixels in radius is 1
double[] val = new double[image.ChannelsCount];
for(int dx = -R; dx <= R; ++dx)
{
for(int dy = -R; dy <= R; ++dy)
{
double inf = influence[dx + R, dy + R] * infScale;
// Store color for new point considering influence from neighbours
int ix = Math.Max(0, Math.Min(image.ColumnCount - 1, oldPixel.X + dx));
int iy = Math.Max(0, Math.Min(image.RowCount - 1, oldPixel.Y + dy));
for(int i = 0; i < image.ChannelsCount; ++i)
{
val[i] += image[iy, ix, i] * inf;
}
}
}
for(int i = 0; i < image.ChannelsCount; ++i)
{
matrices[i].At(y, x, val[i]);
}
}
}
}
return undistorted;
}