|
private static void CopyImagePixels(ICogImage src, Cognex.VisionPro.ICogRegion srcRegion, ICogImage dest, double destAlignmentX, double destAlignmentY)
{
if(null == src)
{
return;
}
CogImage16Range test = src as CogImage16Range;
CogImage16Range destNew = dest as CogImage16Range;
CogRectangle rectangle = srcRegion as CogRectangle;
if (false == destNew.Allocated)
{
destNew.Allocate((int)(rectangle.Width), (int)(rectangle.Height));
}
//test.GetPixel(0, 0, out bool VisibleValue, out ushort PixelValue);
for(double row = rectangle.X; row < rectangle.X + rectangle.Width; row += 100)
{
for (double col = rectangle.Y; col < rectangle.Y + rectangle.Height; col += 100)
{
int newRow = (int)(row - rectangle.X);
int newCol = (int)(col - rectangle.Y);
test.GetPixel((int)row, (int)col, out bool VisibleValue, out ushort PixelValue);
destNew.SetPixel(newRow, newCol, VisibleValue, 2550);
}
}
dest = destNew;
} |
|