本文整理汇总了C#中IImage.SetPixel方法的典型用法代码示例。如果您正苦于以下问题:C# IImage.SetPixel方法的具体用法?C# IImage.SetPixel怎么用?C# IImage.SetPixel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IImage
的用法示例。
在下文中一共展示了IImage.SetPixel方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleFindResults
public void HandleFindResults(IImage image, IEnumerable<IFindResult> results)
{
foreach (var selectedArea in results)
{
if (selectedArea.Points.Count >= 2)
{
var rand = new Random();
var pixel = _pixels[rand.Next(_pixels.Length - 1)];
DrawLineAlgorithm.PlotFunction plotFunction = (x, y) =>
{
if (x < image.Width && y < image.Height && x >= 0 && y >= 0)
{
image.SetPixel(x, y, pixel);
}
return true;
};
var firstPoint = selectedArea.Points[0];
var previousPoint = firstPoint;
for (int i = 1; i < selectedArea.Points.Count; i++)
{
var currentPoint = selectedArea.Points[i];
DrawLineAlgorithm.Line(previousPoint.X, previousPoint.Y, currentPoint.X, currentPoint.Y, plotFunction);
previousPoint = currentPoint;
}
if (selectedArea.Points.Count > 2)
{
var lastPoint = selectedArea.Points[selectedArea.Points.Count - 1];
DrawLineAlgorithm.Line(lastPoint.X, lastPoint.Y, firstPoint.X, firstPoint.Y, plotFunction);
}
}
}
}
示例2: median_filter
//Bitmap my_bitmap
//МЕДИАННЫЙ ФИЛЬТР!!!!!!!!!!
private void median_filter(IImage image, int x, int y)
{
int n;//элемнты в массиве
int cR_, cB_, cG_;//искомые медианные значения
int k = 1;
n = (2 * rad + 1) * (2 * rad + 1); //?
// toolStripProgressBar2.Step = 1;
// toolStripProgressBar2.Maximum = n;
// обнуляем массив ---------------------------
int[] cR = new int[n + 1];
int[] cB = new int[n + 1];
int[] cG = new int[n + 1];
for (int i = 0; i < n + 1; i++)
{
cR[i] = 0;
cG[i] = 0;
cB[i] = 0;
}
//--------------------------------------------
int w_b = image.Width;
int h_b = image.Height;
for (int i = x - rad; i < x + rad + 1; i++)
{
for (int j = y - rad; j < y + rad + 1; j++)
{
Pixel pixel = image.GetPixel(i, j);
cR[k] = Convert.ToInt32(pixel.R);
cG[k] = Convert.ToInt32(pixel.G);
cB[k] = Convert.ToInt32(pixel.B);
k++;
}
}
quicksort(cR, 0, n - 1);//сортируем массивы
quicksort(cG, 0, n - 1);
quicksort(cB, 0, n - 1);
int n_ = (int)(n / 2) + 1;
cR_ = cR[n_];
cG_ = cG[n_];
cB_ = cB[n_];
image.SetPixel(x, y, new Pixel { R = (byte)cR_, G = (byte)cG_, B = (byte)cB_ });
}
示例3: ProcessImage
public void ProcessImage(IImage image)
{
byte[,] indencity = GetIndencityFromImage(image);
for (int x = 0; x < image.Width; x++)
{
for (int y = 0; y < image.Height; y++)
{
var middle = GetMiddlePixelArea(x, y, image, indencity);
var pixel = indencity[x, y];
if (pixel > middle + noise)
{
image.SetPixel(x, y, new Pixel { R = 255, G = 255, B = 255 });
}
else
{
image.SetPixel(x, y, new Pixel());
}
}
}
}
示例4: ProcessImage
public void ProcessImage(IImage image)
{
byte threshold = OtsuTreshold(image);
for (int i = 0; i < image.Width; i++)
{
for (int j = 0; j < image.Height; j++)
{
byte red = image.GetPixel(i, j).R;
byte newPixel = red > threshold ? (byte)255 : (byte)0;
image.SetPixel(i, j, new Pixel { B = newPixel, G = newPixel, R = newPixel });
}
}
}
示例5: Filter
public void Filter(IImage image, double[,] filter)
{
if (filter.GetLength(0) != filter.GetLength(1))
{
throw new ArgumentException("invalid filter", nameof(filter));
}
var result = new Pixel[image.Width, image.Height];
double blue = 0.0;
double green = 0.0;
double red = 0.0;
int filterOffset = (filter.GetLength(0) - 1) / 2;
for (int offsetY = filterOffset; offsetY < image.Height - filterOffset; offsetY++)
{
for (int offsetX = filterOffset; offsetX < image.Width - filterOffset; offsetX++)
{
blue = 0;
green = 0;
red = 0;
for (int filterY = -filterOffset; filterY <= filterOffset; filterY++)
{
for (int filterX = -filterOffset; filterX <= filterOffset; filterX++)
{
var imagePixel = image.GetPixel(offsetX + filterX, offsetY + filterY);
blue += (double)(imagePixel.B) * filter[filterY + filterOffset, filterX + filterOffset];
green += (double)(imagePixel.G) * filter[filterY + filterOffset, filterX + filterOffset];
red += (double)(imagePixel.R) * filter[filterY + filterOffset, filterX + filterOffset];
}
}
blue = Factor * blue + Bias;
green = Factor * green + Bias;
red = Factor * red + Bias;
result[offsetX, offsetY] = new Pixel { R = this.ToByte(red), G = this.ToByte(green), B = this.ToByte(blue) };
}
}
for (int x = 0; x < result.GetLength(0); x++)
{
for (int y = 0; y < result.GetLength(1); y++)
{
image.SetPixel(x, y, result[x, y]);
}
}
}
示例6: ProcessImage
public void ProcessImage(IImage image)
{
Pixel c;
byte[] gammaArray = CreateGammaArray(GammaValue);
for (int i = 0; i < image.Width; i++)
{
for (int j = 0; j < image.Height; j++)
{
c = image.GetPixel(i, j);
image.SetPixel(i, j, new Pixel { R = gammaArray[c.R], G = gammaArray[c.G], B = gammaArray[c.B] });
}
}
}
示例7: ProcessImage
public void ProcessImage(IImage inputImage)
{
var segments = _segmentationAlgoritm.ProcessImage(inputImage);
var image = segments.SegmentationMatrix;
for (int j = 0; j < inputImage.Height; j++)
{
for (int i = 0; i < inputImage.Width; i++)
{
var random = new Random(image[i, j]);
var pixel = new Pixel { R = (byte)random.Next(255), G = (byte)random.Next(255), B = (byte)random.Next(255) };
inputImage.SetPixel(i, j, pixel);
}
}
}
示例8: 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 });
}
}
}