本文整理汇总了C#中System.Image.Copy方法的典型用法代码示例。如果您正苦于以下问题:C# Image.Copy方法的具体用法?C# Image.Copy怎么用?C# Image.Copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Image
的用法示例。
在下文中一共展示了Image.Copy方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Segment
public System.Drawing.Bitmap Segment(System.Drawing.Bitmap image, Image<Bgr, Byte> originalImage, System.Drawing.Rectangle rect)
{
_totalImage = new Image<Bgr, byte>(image);
_mask = _totalImage.GrabCut(rect, ITERATIONCOUNT);
CvInvoke.cvAndS(_mask.Ptr, new MCvScalar(1d), _mask.Ptr, IntPtr.Zero);
Image<Bgr, Byte> result = originalImage.Copy(_mask);
return result.ToBitmap();
}
示例2: ComparingThread
public ComparingThread(Image<Bgr, byte> imgDB, Image<Bgr, byte> imgReal, int i)
{
this.imgOrig = imgDB.Copy();
ImageClass.CleanupSign(this.imgOrig);
this.imgCmp = imgReal.Copy();
this.isFinish = false;
this.signPos = i;
}
示例3: AccumulateBackground
/// <summary>
/// Learns the background statisitics for one more frame.
/// </summary>
/// <param name="image">Image to be accumulated for learning background statistics.</param>
public void AccumulateBackground(Image<Gray, Single> image)
{
if (!first) {
avg.Acc(image);
CvInvoke.cvAbsDiff(image.Ptr, prev.Ptr, tmp1.Ptr);
diff.Acc(tmp1);
Count++;
}
first = false;
prev = image.Copy();
}
示例4: ProcessAndView
public override Image<Rgb, byte> ProcessAndView(Image<Rgb, byte> image)
{
var outputImage = new Image<Rgb, byte>(image.Size.Width, image.Size.Height, Rgbs.Black);
var debugImage = outputImage.Copy();
//Convert the image to grayscale and filter out the noise
var grayImage = image.Convert<Gray, Byte>();
using (var storage = new MemStorage())
{
for (var contours = grayImage.FindContours(CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_SIMPLE, IsRetrieveExternal ? RETR_TYPE.CV_RETR_EXTERNAL : RETR_TYPE.CV_RETR_LIST, storage); contours != null; contours = contours.HNext)
{
var currentContour = contours.ApproxPoly(contours.Perimeter * 0.05, storage);
//Console.WriteLine("AREA {0}", currentContour.Area);
//if (currentContour.Area > MinContourArea) //only consider contours with area greater than 250
//{
//outputImage.Draw(currentContour.GetConvexHull(ORIENTATION.CV_CLOCKWISE), Rgbs.White, 2);
outputImage.FillConvexPoly(currentContour.GetConvexHull(ORIENTATION.CV_CLOCKWISE).ToArray(), Rgbs.White);
if (IsRenderContent)
debugImage.FillConvexPoly(currentContour.GetConvexHull(ORIENTATION.CV_CLOCKWISE).ToArray(), Rgbs.White);
//}
//else
//{
// if (IsRenderContent)
// debugImage.FillConvexPoly(currentContour.GetConvexHull(ORIENTATION.CV_CLOCKWISE).ToArray(), Rgbs.Red);
//}
}
}
Task.Factory.StartNew(() =>
{
var bitmapSource = debugImage.ToBitmapSource(true);
debugImage.Dispose();
return bitmapSource;
}).ContinueWith(t => DebugImageSource = t.Result);
grayImage.Dispose();
return outputImage;
}
示例5: stripBorder
public static Image<Gray, Byte> stripBorder(Image<Gray, Byte> image, Gray threshold)
{
bool found;
int left;
found = false;
for (left = 0; left < image.Cols; left++)
{
for (int r = 0; r < image.Rows && !found; ++r)
if (image[r, left].Intensity >= threshold.Intensity)
found = true;
if (found) break;
}
int right;
found = false;
for (right = image.Cols - 1; right >= 0; right--)
{
for (int r = 0; r < image.Rows && !found; ++r)
if (image[r, right].Intensity >= threshold.Intensity)
found = true;
if (found) break;
}
int top;
found = false;
for (top = 0; top < image.Rows; top++)
{
for (int c = 0; c < image.Cols && !found; ++c)
if (image[top, c].Intensity >= threshold.Intensity)
found = true;
if (found) break;
}
int bottom;
found = false;
for (bottom = image.Rows - 1; bottom >= 0; bottom--)
{
for (int c = 0; c < image.Cols && !found; ++c)
if (image[bottom, c].Intensity >= threshold.Intensity)
found = true;
if (found) break;
}
if (right < left)
{
left = 0;
right = 0;
}
if (bottom < top)
{
top = 0;
bottom = 0;
}
return image.Copy(new System.Drawing.Rectangle(left, top, right-left + 1, bottom-top + 1));
}
示例6: WriteImages
public void WriteImages( Image targetImage )
{
if (tex!=null) {
targetImage.Copy( x + padding, y + padding, tex );
}
if (left!=null) left.WriteImages( targetImage );
if (right!=null) right.WriteImages( targetImage );
}
示例7: Median
internal static void Median(Image<Bgr, byte> img)
{
unsafe
{
//new copy
Image<Bgr, Byte> imgcopy = img.Copy();
MIplImage m2 = imgcopy.MIplImage;
byte* dataPtr2 = (byte*)m2.imageData.ToPointer();
int nChan2 = m2.nChannels;
int padding2 = m2.widthStep - m2.nChannels * m2.width;
// get the pointer to the beginning of the image
MIplImage m = img.MIplImage;
byte* dataPtr = (byte*)m.imageData.ToPointer();
int width = img.Width;
int height = img.Height;
int nChan = m.nChannels; // numero de canais 3
int padding = m.widthStep - m.nChannels * m.width; // alinhamento (padding)
int widthStep = m.widthStep;
int widthStep2 = m2.widthStep;
int width2 = imgcopy.Width;
int height2 = imgcopy.Height;
byte* dataPtrpom = dataPtr;
byte* dataPtrpom2 = dataPtr2;
int[] pixels = new int[3];
pixels[0] = 0;
pixels[1] = 0;
pixels[2] = 0;
//centre
dataPtr += widthStep + nChan;
dataPtr2 += widthStep2 + nChan2;
int[] values = new int[9];
for (int y = 1; y < height - 1; y++)
{
for (int x = 1; x < width - 1; x++)
{
values[0] = Math.Abs((dataPtr2 - widthStep2 - nChan2)[0] - (dataPtr2 - widthStep2)[0]) + Math.Abs((dataPtr2 - widthStep2 - nChan2)[1] - (dataPtr2 - widthStep2)[1]) + Math.Abs((dataPtr2 - widthStep2 - nChan2)[2] - (dataPtr2 - widthStep2)[2])
+ Math.Abs((dataPtr2 - widthStep2 - nChan2)[0] - (dataPtr2 - widthStep2 + nChan2)[0]) + Math.Abs((dataPtr2 - widthStep2 - nChan2)[1] - (dataPtr2 - widthStep2 + nChan2)[1]) + Math.Abs((dataPtr2 - widthStep2 - nChan2)[2] - (dataPtr2 - widthStep2 + nChan2)[2])
+ Math.Abs((dataPtr2 - widthStep2 - nChan2)[0] - (dataPtr2 - nChan2)[0]) + Math.Abs((dataPtr2 - widthStep2 - nChan2)[1] - (dataPtr2 - nChan2)[1]) + Math.Abs((dataPtr2 - widthStep2 - nChan2)[2] - (dataPtr2 - nChan2)[2])
+ Math.Abs((dataPtr2 - widthStep2 - nChan2)[0] - dataPtr2[0]) + Math.Abs((dataPtr2 - widthStep2 - nChan2)[1] - dataPtr2[1]) + Math.Abs((dataPtr2 - widthStep2 - nChan2)[2] - dataPtr2[2])
+ Math.Abs((dataPtr2 - widthStep2 - nChan2)[0] - (dataPtr2 + nChan2)[0]) + Math.Abs((dataPtr2 - widthStep2 - nChan2)[1] - (dataPtr2 + nChan2)[1]) + Math.Abs((dataPtr2 - widthStep2 - nChan2)[2] - (dataPtr2 + nChan2)[2])
+ Math.Abs((dataPtr2 - widthStep2 - nChan2)[0] - (dataPtr2 + widthStep2 - nChan2)[0]) + Math.Abs((dataPtr2 - widthStep2 - nChan2)[1] - (dataPtr2 + widthStep2 - nChan2)[1]) + Math.Abs((dataPtr2 - widthStep2 - nChan2)[2] - (dataPtr2 + widthStep2 - nChan2)[2])
+ Math.Abs((dataPtr2 - widthStep2 - nChan2)[0] - (dataPtr2 + widthStep2)[0]) + Math.Abs((dataPtr2 - widthStep2 - nChan2)[1] - (dataPtr2 + widthStep2)[1]) + Math.Abs((dataPtr2 - widthStep2 - nChan2)[2] - (dataPtr2 + widthStep2)[2])
+ Math.Abs((dataPtr2 - widthStep2 - nChan2)[0] - (dataPtr2 + widthStep2 + nChan2)[0]) + Math.Abs((dataPtr2 - widthStep2 - nChan2)[1] - (dataPtr2 + widthStep2 + nChan2)[1]) + Math.Abs((dataPtr2 - widthStep2 - nChan2)[2] - (dataPtr2 + widthStep2 + nChan2)[2]);
values[1] = Math.Abs((dataPtr2 - widthStep2)[0] - (dataPtr2 - widthStep2 - nChan2)[0]) + Math.Abs((dataPtr2 - widthStep2)[1] - (dataPtr2 - widthStep2 - nChan2)[1]) + Math.Abs((dataPtr2 - widthStep2)[2] - (dataPtr2 - widthStep2 - nChan2)[2])
+ Math.Abs((dataPtr2 - widthStep2)[0] - (dataPtr2 - widthStep2 + nChan2)[0]) + Math.Abs((dataPtr2 - widthStep2)[1] - (dataPtr2 - widthStep2 + nChan2)[1]) + Math.Abs((dataPtr2 - widthStep2)[2] - (dataPtr2 - widthStep2 + nChan2)[2])
+ Math.Abs((dataPtr2 - widthStep2)[0] - (dataPtr2 - nChan2)[0]) + Math.Abs((dataPtr2 - widthStep2)[1] - (dataPtr2 - nChan2)[1]) + Math.Abs((dataPtr2 - widthStep2)[2] - (dataPtr2 - nChan2)[2])
+ Math.Abs((dataPtr2 - widthStep2)[0] - dataPtr2[0]) + Math.Abs((dataPtr2 - widthStep2)[1] - dataPtr2[1]) + Math.Abs((dataPtr2 - widthStep2)[2] - dataPtr2[2])
+ Math.Abs((dataPtr2 - widthStep2)[0] - (dataPtr2 + nChan2)[0]) + Math.Abs((dataPtr2 - widthStep2)[1] - (dataPtr2 + nChan2)[1]) + Math.Abs((dataPtr2 - widthStep2)[2] - (dataPtr2 + nChan2)[2])
+ Math.Abs((dataPtr2 - widthStep2)[0] - (dataPtr2 + widthStep2 - nChan2)[0]) + Math.Abs((dataPtr2 - widthStep2)[1] - (dataPtr2 + widthStep2 - nChan2)[1]) + Math.Abs((dataPtr2 - widthStep2)[2] - (dataPtr2 + widthStep2 - nChan2)[2])
+ Math.Abs((dataPtr2 - widthStep2)[0] - (dataPtr2 + widthStep2)[0]) + Math.Abs((dataPtr2 - widthStep2)[1] - (dataPtr2 + widthStep2)[1]) + Math.Abs((dataPtr2 - widthStep2)[2] - (dataPtr2 + widthStep2)[2])
+ Math.Abs((dataPtr2 - widthStep2)[0] - (dataPtr2 + widthStep2 + nChan2)[0]) + Math.Abs((dataPtr2 - widthStep2)[1] - (dataPtr2 + widthStep2 + nChan2)[1]) + Math.Abs((dataPtr2 - widthStep2)[2] - (dataPtr2 + widthStep2 + nChan2)[2]);
values[2] = Math.Abs((dataPtr2 - widthStep2 + nChan2)[0] - (dataPtr2 - widthStep2)[0]) + Math.Abs((dataPtr2 - widthStep2 + nChan2)[1] - (dataPtr2 - widthStep2)[1]) + Math.Abs((dataPtr2 - widthStep2 + nChan2)[2] - (dataPtr2 - widthStep2)[2])
+ Math.Abs((dataPtr2 - widthStep2 + nChan2)[0] - (dataPtr2 - widthStep2 - nChan2)[0]) + Math.Abs((dataPtr2 - widthStep2 + nChan2)[1] - (dataPtr2 - widthStep2 - nChan2)[1]) + Math.Abs((dataPtr2 - widthStep2 + nChan2)[2] - (dataPtr2 - widthStep2 - nChan2)[2])
+ Math.Abs((dataPtr2 - widthStep2 + nChan2)[0] - (dataPtr2 - nChan2)[0]) + Math.Abs((dataPtr2 - widthStep2 + nChan2)[1] - (dataPtr2 - nChan2)[1]) + Math.Abs((dataPtr2 - widthStep2 + nChan2)[2] - (dataPtr2 - nChan2)[2])
+ Math.Abs((dataPtr2 - widthStep2 + nChan2)[0] - dataPtr2[0]) + Math.Abs((dataPtr2 - widthStep2 + nChan2)[1] - dataPtr2[1]) + Math.Abs((dataPtr2 - widthStep2 + nChan2)[2] - dataPtr2[2])
+ Math.Abs((dataPtr2 - widthStep2 + nChan2)[0] - (dataPtr2 + nChan2)[0]) + Math.Abs((dataPtr2 - widthStep2 + nChan2)[1] - (dataPtr2 + nChan2)[1]) + Math.Abs((dataPtr2 - widthStep2 + nChan2)[2] - (dataPtr2 + nChan2)[2])
+ Math.Abs((dataPtr2 - widthStep2 + nChan2)[0] - (dataPtr2 + widthStep2 - nChan2)[0]) + Math.Abs((dataPtr2 - widthStep2 + nChan2)[1] - (dataPtr2 + widthStep2 - nChan2)[1]) + Math.Abs((dataPtr2 - widthStep2 + nChan2)[2] - (dataPtr2 + widthStep2 - nChan2)[2])
+ Math.Abs((dataPtr2 - widthStep2 + nChan2)[0] - (dataPtr2 + widthStep2)[0]) + Math.Abs((dataPtr2 - widthStep2 + nChan2)[1] - (dataPtr2 + widthStep2)[1]) + Math.Abs((dataPtr2 - widthStep2 + nChan2)[2] - (dataPtr2 + widthStep2)[2])
+ Math.Abs((dataPtr2 - widthStep2 + nChan2)[0] - (dataPtr2 + widthStep2 + nChan2)[0]) + Math.Abs((dataPtr2 - widthStep2 + nChan2)[1] - (dataPtr2 + widthStep2 + nChan2)[1]) + Math.Abs((dataPtr2 - widthStep2 + nChan2)[2] - (dataPtr2 + widthStep2 + nChan2)[2]);
values[3] = Math.Abs((dataPtr2 - nChan2)[0] - (dataPtr2 - widthStep2)[0]) + Math.Abs((dataPtr2 - nChan2)[1] - (dataPtr2 - widthStep2)[1]) + Math.Abs((dataPtr2 - nChan2)[2] - (dataPtr2 - widthStep2)[2])
+ Math.Abs((dataPtr2 - nChan2)[0] - (dataPtr2 - widthStep2 + nChan2)[0]) + Math.Abs((dataPtr2 - nChan2)[1] - (dataPtr2 - widthStep2 + nChan2)[1]) + Math.Abs((dataPtr2 - nChan2)[2] - (dataPtr2 - widthStep2 + nChan2)[2])
+ Math.Abs((dataPtr2 - nChan2)[0] - (dataPtr2 - widthStep2 - nChan2)[0]) + Math.Abs((dataPtr2 - nChan2)[1] - (dataPtr2 - widthStep2 - nChan2)[1]) + Math.Abs((dataPtr2 - nChan2)[2] - (dataPtr2 - widthStep2 - nChan2)[2])
+ Math.Abs((dataPtr2 - nChan2)[0] - dataPtr2[0]) + Math.Abs((dataPtr2 - nChan2)[1] - dataPtr2[1]) + Math.Abs((dataPtr2 - nChan2)[2] - dataPtr2[2])
+ Math.Abs((dataPtr2 - nChan2)[0] - (dataPtr2 + nChan2)[0]) + Math.Abs((dataPtr2 - nChan2)[1] - (dataPtr2 + nChan2)[1]) + Math.Abs((dataPtr2 - nChan2)[2] - (dataPtr2 + nChan2)[2])
+ Math.Abs((dataPtr2 - nChan2)[0] - (dataPtr2 + widthStep2 - nChan2)[0]) + Math.Abs((dataPtr2 - nChan2)[1] - (dataPtr2 + widthStep2 - nChan2)[1]) + Math.Abs((dataPtr2 - nChan2)[2] - (dataPtr2 + widthStep2 - nChan2)[2])
+ Math.Abs((dataPtr2 - nChan2)[0] - (dataPtr2 + widthStep2)[0]) + Math.Abs((dataPtr2 - nChan2)[1] - (dataPtr2 + widthStep2)[1]) + Math.Abs((dataPtr2 - nChan2)[2] - (dataPtr2 + widthStep2)[2])
+ Math.Abs((dataPtr2 - nChan2)[0] - (dataPtr2 + widthStep2 + nChan2)[0]) + Math.Abs((dataPtr2 - nChan2)[1] - (dataPtr2 + widthStep2 + nChan2)[1]) + Math.Abs((dataPtr2 - nChan2)[2] - (dataPtr2 + widthStep2 + nChan2)[2]);
values[4] = Math.Abs((dataPtr2)[0] - (dataPtr2 - widthStep2)[0]) + Math.Abs((dataPtr2)[1] - (dataPtr2 - widthStep2)[1]) + Math.Abs((dataPtr2)[2] - (dataPtr2 - widthStep2)[2])
+ Math.Abs((dataPtr2)[0] - (dataPtr2 - widthStep2 + nChan2)[0]) + Math.Abs((dataPtr2)[1] - (dataPtr2 - widthStep2 + nChan2)[1]) + Math.Abs((dataPtr2)[2] - (dataPtr2 - widthStep2 + nChan2)[2])
+ Math.Abs((dataPtr2)[0] - (dataPtr2 - nChan2)[0]) + Math.Abs((dataPtr2)[1] - (dataPtr2 - nChan2)[1]) + Math.Abs((dataPtr2)[2] - (dataPtr2 - nChan2)[2])
+ Math.Abs((dataPtr2)[0] - (dataPtr2 - widthStep2 - nChan2)[0]) + Math.Abs((dataPtr2)[1] - (dataPtr2 - widthStep2 - nChan2)[1]) + Math.Abs((dataPtr2)[2] - (dataPtr2 - widthStep2 - nChan2)[2])
+ Math.Abs((dataPtr2)[0] - (dataPtr2 + nChan2)[0]) + Math.Abs((dataPtr2)[1] - (dataPtr2 + nChan2)[1]) + Math.Abs((dataPtr2)[2] - (dataPtr2 + nChan2)[2])
+ Math.Abs((dataPtr2)[0] - (dataPtr2 + widthStep2 - nChan2)[0]) + Math.Abs((dataPtr2)[1] - (dataPtr2 + widthStep2 - nChan2)[1]) + Math.Abs((dataPtr2)[2] - (dataPtr2 + widthStep2 - nChan2)[2])
+ Math.Abs((dataPtr2)[0] - (dataPtr2 + widthStep2)[0]) + Math.Abs((dataPtr2)[1] - (dataPtr2 + widthStep2)[1]) + Math.Abs((dataPtr2)[2] - (dataPtr2 + widthStep2)[2])
+ Math.Abs((dataPtr2)[0] - (dataPtr2 + widthStep2 + nChan2)[0]) + Math.Abs((dataPtr2)[1] - (dataPtr2 + widthStep2 + nChan2)[1]) + Math.Abs((dataPtr2)[2] - (dataPtr2 + widthStep2 + nChan2)[2]);
values[5] = Math.Abs((dataPtr2 + nChan2)[0] - (dataPtr2 - widthStep2)[0]) + Math.Abs((dataPtr2 + nChan2)[1] - (dataPtr2 - widthStep2)[1]) + Math.Abs((dataPtr2 + nChan2)[2] - (dataPtr2 - widthStep2)[2])
+ Math.Abs((dataPtr2 + nChan2)[0] - (dataPtr2 - widthStep2 + nChan2)[0]) + Math.Abs((dataPtr2 + nChan2)[1] - (dataPtr2 - widthStep2 + nChan2)[1]) + Math.Abs((dataPtr2 + nChan2)[2] - (dataPtr2 - widthStep2 + nChan2)[2])
+ Math.Abs((dataPtr2 + nChan2)[0] - (dataPtr2 - nChan2)[0]) + Math.Abs((dataPtr2 + nChan2)[1] - (dataPtr2 - nChan2)[1]) + Math.Abs((dataPtr2 + nChan2)[2] - (dataPtr2 - nChan2)[2])
+ Math.Abs((dataPtr2 + nChan2)[0] - dataPtr2[0]) + Math.Abs((dataPtr2 + nChan2)[1] - dataPtr2[1]) + Math.Abs((dataPtr2 + nChan2)[2] - dataPtr2[2])
+ Math.Abs((dataPtr2 + nChan2)[0] - (dataPtr2 - widthStep2 - nChan2)[0]) + Math.Abs((dataPtr2 - widthStep2 - nChan2)[1] - (dataPtr2 + nChan2)[1]) + Math.Abs((dataPtr2 - widthStep2 - nChan2)[2] - (dataPtr2 + nChan2)[2])
+ Math.Abs((dataPtr2 + nChan2)[0] - (dataPtr2 + widthStep2 - nChan2)[0]) + Math.Abs((dataPtr2 + nChan2)[1] - (dataPtr2 + widthStep2 - nChan2)[1]) + Math.Abs((dataPtr2 + nChan2)[2] - (dataPtr2 + widthStep2 - nChan2)[2])
+ Math.Abs((dataPtr2 + nChan2)[0] - (dataPtr2 + widthStep2)[0]) + Math.Abs((dataPtr2 + nChan2)[1] - (dataPtr2 + widthStep2)[1]) + Math.Abs((dataPtr2 + nChan2)[2] - (dataPtr2 + widthStep2)[2])
+ Math.Abs((dataPtr2 + nChan2)[0] - (dataPtr2 + widthStep2 + nChan2)[0]) + Math.Abs((dataPtr2 + nChan2)[1] - (dataPtr2 + widthStep2 + nChan2)[1]) + Math.Abs((dataPtr2 + nChan2)[2] - (dataPtr2 + widthStep2 + nChan2)[2]);
values[6] = Math.Abs((dataPtr2 + widthStep2 - nChan2)[0] - (dataPtr2 - widthStep2)[0]) + Math.Abs((dataPtr2 + widthStep2 - nChan2)[1] - (dataPtr2 - widthStep2)[1]) + Math.Abs((dataPtr2 + widthStep2 - nChan2)[2] - (dataPtr2 - widthStep2)[2])
+ Math.Abs((dataPtr2 + widthStep2 - nChan2)[0] - (dataPtr2 - widthStep2 + nChan2)[0]) + Math.Abs((dataPtr2 + widthStep2 - nChan2)[1] - (dataPtr2 - widthStep2 + nChan2)[1]) + Math.Abs((dataPtr2 + widthStep2 - nChan2)[2] - (dataPtr2 - widthStep2 + nChan2)[2])
+ Math.Abs((dataPtr2 + widthStep2 - nChan2)[0] - (dataPtr2 - nChan2)[0]) + Math.Abs((dataPtr2 + widthStep2 - nChan2)[1] - (dataPtr2 - nChan2)[1]) + Math.Abs((dataPtr2 + widthStep2 - nChan2)[2] - (dataPtr2 - nChan2)[2])
+ Math.Abs((dataPtr2 + widthStep2 - nChan2)[0] - dataPtr2[0]) + Math.Abs((dataPtr2 + widthStep2 - nChan2)[1] - dataPtr2[1]) + Math.Abs((dataPtr2 + widthStep2 - nChan2)[2] - dataPtr2[2])
+ Math.Abs((dataPtr2 + widthStep2 - nChan2)[0] - (dataPtr2 + nChan2)[0]) + Math.Abs((dataPtr2 + widthStep2 - nChan2)[1] - (dataPtr2 + nChan2)[1]) + Math.Abs((dataPtr2 + widthStep2 - nChan2)[2] - (dataPtr2 + nChan2)[2])
+ Math.Abs((dataPtr2 + widthStep2 - nChan2)[0] - (dataPtr2 + widthStep2 - nChan2)[0]) + Math.Abs((dataPtr2 - widthStep2 - nChan2)[1] - (dataPtr2 + widthStep2 - nChan2)[1]) + Math.Abs((dataPtr2 - widthStep2 - nChan2)[2] - (dataPtr2 + widthStep2 - nChan2)[2])
+ Math.Abs((dataPtr2 + widthStep2 - nChan2)[0] - (dataPtr2 + widthStep2)[0]) + Math.Abs((dataPtr2 + widthStep2 - nChan2)[1] - (dataPtr2 + widthStep2)[1]) + Math.Abs((dataPtr2 - widthStep2 - nChan2)[2] - (dataPtr2 + widthStep2)[2])
//.........这里部分代码省略.........
示例8: NoiseReduction
/*this is the function to be checked*/
internal static void NoiseReduction(Image<Bgr, byte> img, int w11, int w12, int w13, int w21, int w22, int w23, int w31, int w32, int w33, double wmain)
{
unsafe
{
//new copy
Image<Bgr, Byte> imgcopy = img.Copy();
MIplImage m2 = imgcopy.MIplImage;
byte* dataPtr2 = (byte*)m2.imageData.ToPointer();
int nChan2 = m2.nChannels;
int padding2 = m2.widthStep - m2.nChannels * m2.width;
// get the pointer to the beginning of the image
MIplImage m = img.MIplImage;
byte* dataPtr = (byte*)m.imageData.ToPointer();
int width = img.Width;
int height = img.Height;
int nChan = m.nChannels; // numero de canais 3
int padding = m.widthStep - m.nChannels * m.width; // alinhamento (padding)
int widthStep = m.widthStep;
int widthStep2 = m2.widthStep;
int width2 = imgcopy.Width;
int height2 = imgcopy.Height;
byte* dataPtrpom = dataPtr;
byte* dataPtrpom2 = dataPtr2;
int[] pixels = new int[3];
pixels[0] = 0;
pixels[1] = 0;
pixels[2] = 0;
//centre
dataPtr += widthStep + nChan;
dataPtr2 += widthStep2 + nChan2;
for (int y = 1; y < height - 1; y++)
{
for (int x = 1; x < width - 1; x++)
{
pixels[0] += (dataPtr2 - widthStep2 - nChan2)[0] * w11;
pixels[1] += (dataPtr2 - widthStep2 - nChan2)[1] * w11;
pixels[2] += (dataPtr2 - widthStep2 - nChan2)[2] * w11;
pixels[0] += (dataPtr2 - widthStep2)[0] * w12;
pixels[1] += (dataPtr2 - widthStep2)[1] * w12;
pixels[2] += (dataPtr2 - widthStep2)[2] * w12;
pixels[0] += (dataPtr2 - widthStep2 + nChan2)[0] * w13;
pixels[1] += (dataPtr2 - widthStep2 + nChan2)[1] * w13;
pixels[2] += (dataPtr2 - widthStep2 + nChan2)[2] * w13;
pixels[0] += (dataPtr2 - nChan2)[0] * w21;
pixels[1] += (dataPtr2 - nChan2)[1] * w21;
pixels[2] += (dataPtr2 - nChan2)[2] * w21;
pixels[0] += dataPtr2[0] * w22;
pixels[1] += dataPtr2[1] * w22;
pixels[2] += dataPtr2[2] * w22;
pixels[0] += (dataPtr2 + nChan2)[0] * w23;
pixels[1] += (dataPtr2 + nChan2)[1] * w23;
pixels[2] += (dataPtr2 + nChan2)[2] * w23;
pixels[0] += (dataPtr2 + widthStep2 - nChan2)[0] * w31;
pixels[1] += (dataPtr2 + widthStep2 - nChan2)[1] * w31;
pixels[2] += (dataPtr2 + widthStep2 - nChan2)[2] * w31;
pixels[0] += (dataPtr2 + widthStep2)[0] * w32;
pixels[1] += (dataPtr2 + widthStep2)[1] * w32;
pixels[2] += (dataPtr2 + widthStep2)[2] * w32;
pixels[0] += (dataPtr2 + widthStep2 + nChan2)[0] * w33;
pixels[1] += (dataPtr2 + widthStep2 + nChan2)[1] * w33;
pixels[2] += (dataPtr2 + widthStep2 + nChan2)[2] * w33;
pixels[0] = Convert.ToInt32(pixels[0] / wmain);
pixels[1] = Convert.ToInt32(pixels[1] / wmain);
pixels[2] = Convert.ToInt32(pixels[2] / wmain);
if (pixels[0] > 255)
pixels[0] = 255;
if (pixels[1] > 255)
pixels[1] = 255;
if (pixels[2] > 255)
pixels[2] = 255;
if (pixels[0] < 0)
pixels[0] = 0;
if (pixels[1] < 0)
pixels[1] = 0;
if (pixels[2] < 0)
pixels[2] = 0;
dataPtr[0] = Convert.ToByte(pixels[0]);
dataPtr[1] = Convert.ToByte(pixels[1]);
dataPtr[2] = Convert.ToByte(pixels[2]);
pixels[0] = 0;
pixels[1] = 0;
pixels[2] = 0;
dataPtr += nChan;
dataPtr2 += nChan2;
}
dataPtr += 2 * nChan + padding;
dataPtr2 += 2 * nChan2 + padding2;
}
dataPtr = dataPtrpom;
dataPtr2 = dataPtrpom2;
int[] sum = new int[3]; //left top corner
//.........这里部分代码省略.........
示例9: Translate
internal static void Translate(Image<Bgr, byte> img, int movex, int movey)
{
unsafe
{
//new copy
Image<Bgr, Byte> imgcopy = img.Copy();
MIplImage m2 = imgcopy.MIplImage;
byte* dataPtr2 = (byte*)m2.imageData.ToPointer();
int nChan2 = m2.nChannels;
int padding2 = m2.widthStep - m2.nChannels * m2.width;
// get the pointer to the beginning of the image
MIplImage m = img.MIplImage;
byte* dataPtr = (byte*)m.imageData.ToPointer();
int width = img.Width;
int height = img.Height;
int nChan = m.nChannels; // numero de canais 3
int padding = m.widthStep - m.nChannels * m.width; // alinhamento (padding)
byte* dataPtrpom = dataPtr;
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
if (x < movex)
{
dataPtr[0] = 0;
dataPtr[1] = 0;
dataPtr[2] = 0;
}
if (y < movey)
{
dataPtr[0] = 0;
dataPtr[1] = 0;
dataPtr[2] = 0;
}
dataPtr += nChan;
}
dataPtr += padding;
}
dataPtr = dataPtrpom;
for (int i = 0; i < movey; i++)
{
dataPtr += nChan*width;
dataPtr += padding;
}
dataPtr += nChan*movex;
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
dataPtr[0] = dataPtr2[0];
dataPtr[1] = dataPtr2[1];
dataPtr[2] = dataPtr2[2];
dataPtr2 += nChan2;
if(x<width-movex)
dataPtr += nChan;
}
dataPtr2 += padding2;
dataPtr += padding;
dataPtr += nChan*movex;
}
}
}
示例10: Sobel
internal static void Sobel(Image<Bgr, byte> img)
{
unsafe
{
//new copy
Image<Bgr, Byte> imgcopy = img.Copy();
MIplImage m2 = imgcopy.MIplImage;
byte* dataPtr2 = (byte*)m2.imageData.ToPointer();
int nChan2 = m2.nChannels;
int padding2 = m2.widthStep - m2.nChannels * m2.width;
// get the pointer to the beginning of the image
MIplImage m = img.MIplImage;
byte* dataPtr = (byte*)m.imageData.ToPointer();
int width = img.Width;
int height = img.Height;
int nChan = m.nChannels; // numero de canais 3
int padding = m.widthStep - m.nChannels * m.width; // alinhamento (padding)
int widthStep = m.widthStep;
int widthStep2 = m2.widthStep;
int width2 = imgcopy.Width;
int height2 = imgcopy.Height;
byte* dataPtrpom = dataPtr;
byte* dataPtrpom2 = dataPtr2;
int[] pixels1 = new int[3];
int[] pixels2 = new int[3];
int[] s = new int[3];
pixels1[0] = 0;
pixels1[1] = 0;
pixels1[2] = 0;
pixels2[0] = 0;
pixels2[1] = 0;
pixels2[2] = 0;
s[0] = 0;
s[1] = 0;
s[2] = 0;
dataPtr += widthStep + nChan;
dataPtr2 += widthStep + nChan2;
//centre
for (int y = 1; y < height - 1; y++)
{
for (int x = 1; x < width - 1; x++)
{
//left pixels1
pixels1[0] += (dataPtr2 - widthStep2 - nChan2)[0];
pixels1[1] += (dataPtr2 - widthStep2 - nChan2)[1];
pixels1[2] += (dataPtr2 - widthStep2 - nChan2)[2];
pixels1[0] += 2 * (dataPtr2 - nChan2)[0];
pixels1[1] += 2 * (dataPtr2 - nChan2)[1];
pixels1[2] += 2 * (dataPtr2 - nChan2)[2];
pixels1[0] += (dataPtr2 + widthStep - nChan2)[0];
pixels1[1] += (dataPtr2 + widthStep - nChan2)[1];
pixels1[2] += (dataPtr2 + widthStep - nChan2)[2];
//right pixels1
pixels1[0] = pixels1[0] - (dataPtr2 - widthStep2 + nChan2)[0];
pixels1[1] = pixels1[1] - (dataPtr2 - widthStep2 + nChan2)[1];
pixels1[2] = pixels1[2] - (dataPtr2 - widthStep2 + nChan2)[2];
pixels1[0] = pixels1[0] - 2 * (dataPtr2 + nChan2)[0];
pixels1[1] = pixels1[1] - 2 * (dataPtr2 + nChan2)[1];
pixels1[2] = pixels1[2] - 2 * (dataPtr2 + nChan2)[2];
pixels1[0] = pixels1[0] - (dataPtr2 + widthStep + nChan2)[0];
pixels1[1] = pixels1[1] - (dataPtr2 + widthStep + nChan2)[1];
pixels1[2] = pixels1[2] - (dataPtr2 + widthStep + nChan2)[2];
//bottom pixels2
pixels2[0] += (dataPtr2 + widthStep - nChan)[0];
pixels2[1] += (dataPtr2 + widthStep - nChan)[1];
pixels2[2] += (dataPtr2 + widthStep - nChan)[2];
pixels2[0] += 2 * (dataPtr2 + widthStep)[0];
pixels2[1] += 2 * (dataPtr2 + widthStep)[1];
pixels2[2] += 2 * (dataPtr2 + widthStep)[2];
pixels2[0] += (dataPtr2 + widthStep + nChan)[0];
pixels2[1] += (dataPtr2 + widthStep + nChan)[1];
pixels2[2] += (dataPtr2 + widthStep + nChan)[2];
//top pixels2
pixels2[0] = pixels2[0] - (dataPtr2 - widthStep - nChan)[0];
pixels2[1] = pixels2[1] - (dataPtr2 - widthStep - nChan)[1];
pixels2[2] = pixels2[2] - (dataPtr2 - widthStep - nChan)[2];
pixels2[0] = pixels2[0] - 2 * (dataPtr2 - widthStep)[0];
pixels2[1] = pixels2[1] - 2 * (dataPtr2 - widthStep)[1];
pixels2[2] = pixels2[2] - 2 * (dataPtr2 - widthStep)[2];
pixels2[0] = pixels2[0] - (dataPtr2 - widthStep + nChan)[0];
pixels2[1] = pixels2[1] - (dataPtr2 - widthStep + nChan)[1];
pixels2[2] = pixels2[2] - (dataPtr2 - widthStep + nChan)[2];
s[0] = Math.Abs(pixels1[0]) + Math.Abs(pixels2[0]);
s[1] = Math.Abs(pixels1[1]) + Math.Abs(pixels2[1]);
s[2] = Math.Abs(pixels1[2]) + Math.Abs(pixels2[2]);
//check
if (s[0] > 255)
s[0] = 255;
if (s[1] > 255)
s[1] = 255;
if (s[2] > 255)
//.........这里部分代码省略.........
示例11: Scale
internal static void Scale(Image<Bgr, byte> img, double scale)
{
unsafe
{
//new copy
Image<Bgr, Byte> imgcopy = img.Copy();
MIplImage m2 = imgcopy.MIplImage;
byte* dataPtr2 = (byte*)m2.imageData.ToPointer();
int nChan2 = m2.nChannels;
int padding2 = m2.widthStep - m2.nChannels * m2.width;
// get the pointer to the beginning of the image
MIplImage m = img.MIplImage;
byte* dataPtr = (byte*)m.imageData.ToPointer();
int width = img.Width;
int height = img.Height;
int nChan = m.nChannels; // numero de canais 3
int padding = m.widthStep - m.nChannels * m.width; // alinhamento (padding)
byte* dataPtrpom = dataPtr;
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
dataPtr[0] = 0;
dataPtr[1] = 0;
dataPtr[2] = 0;
dataPtr += nChan;
}
dataPtr += padding;
}
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
int newx = Convert.ToInt16(x*scale);
int newy = Convert.ToInt16(y*scale);
dataPtr = dataPtrpom;
if (newx < width & newy < height)
{
for (int i = 0; i < newy; i++)
{
dataPtr += nChan * width;
dataPtr += padding;
}
dataPtr += nChan * newx;
dataPtr[0] = dataPtr2[0];
dataPtr[1] = dataPtr2[1];
dataPtr[2] = dataPtr2[2];
}
dataPtr2 += nChan2;
}
dataPtr2 += padding2;
}
}
}
示例12: Roberts
internal static void Roberts(Image<Bgr, byte> img)
{
unsafe
{
//new copy
Image<Bgr, Byte> imgcopy = img.Copy();
MIplImage m2 = imgcopy.MIplImage;
byte* dataPtr2 = (byte*)m2.imageData.ToPointer();
int nChan2 = m2.nChannels;
int padding2 = m2.widthStep - m2.nChannels * m2.width;
// get the pointer to the beginning of the image
MIplImage m = img.MIplImage;
byte* dataPtr = (byte*)m.imageData.ToPointer();
int width = img.Width;
int height = img.Height;
int nChan = m.nChannels; // numero de canais 3
int padding = m.widthStep - m.nChannels * m.width; // alinhamento (padding)
int widthStep = m.widthStep;
int widthStep2 = m2.widthStep;
int width2 = imgcopy.Width;
int height2 = imgcopy.Height;
byte* dataPtrpom = dataPtr;
byte* dataPtrpom2 = dataPtr2;
int[] pixels = new int[3];
pixels[0] = 0;
pixels[1] = 0;
pixels[2] = 0;
//centre
dataPtr += widthStep;
dataPtr2 += widthStep2;
for (int y = 1; y < height - 1; y++)
{
for (int x = 0; x < width - 1; x++)
{
pixels[0] += Math.Abs(dataPtr2[0] - (dataPtr2 + widthStep2 + nChan2)[0]) + Math.Abs((dataPtr2 + widthStep2)[0] - (dataPtr2 + nChan2)[0]);
pixels[1] += Math.Abs(dataPtr2[1] - (dataPtr2 + widthStep2 + nChan2)[1]) + Math.Abs((dataPtr2 + widthStep2)[1] - (dataPtr2 + nChan2)[1]);
pixels[2] += Math.Abs(dataPtr2[2] - (dataPtr2 + widthStep2 + nChan2)[2]) + Math.Abs((dataPtr2 + widthStep2)[2] - (dataPtr2 + nChan2)[2]);
if (pixels[0] > 255)
pixels[0] = 255;
if (pixels[1] > 255)
pixels[1] = 255;
if (pixels[2] > 255)
pixels[2] = 255;
if (pixels[0] < 0)
pixels[0] = 0;
if (pixels[1] < 0)
pixels[1] = 0;
if (pixels[2] < 0)
pixels[2] = 0;
dataPtr[0] = Convert.ToByte(pixels[0]);
dataPtr[1] = Convert.ToByte(pixels[1]);
dataPtr[2] = Convert.ToByte(pixels[2]);
pixels[0] = 0;
pixels[1] = 0;
pixels[2] = 0;
dataPtr += nChan;
dataPtr2 += nChan2;
}
dataPtr += nChan + padding;
dataPtr2 += nChan2 + padding2;
}
//top
dataPtr = dataPtrpom;
dataPtr2 = dataPtrpom2;
for (int x = 0; x < width2 - 1; x++)
{
pixels[0] += Math.Abs(dataPtr2[0] - (dataPtr2 + widthStep2 + nChan2)[0]) + Math.Abs((dataPtr2 + widthStep2)[0] - (dataPtr2 + nChan2)[0]);
pixels[1] += Math.Abs(dataPtr2[1] - (dataPtr2 + widthStep2 + nChan2)[1]) + Math.Abs((dataPtr2 + widthStep2)[1] - (dataPtr2 + nChan2)[1]);
pixels[2] += Math.Abs(dataPtr2[2] - (dataPtr2 + widthStep2 + nChan2)[2]) + Math.Abs((dataPtr2 + widthStep2)[2] - (dataPtr2 + nChan2)[2]);
if (pixels[0] > 255)
pixels[0] = 255;
if (pixels[1] > 255)
pixels[1] = 255;
if (pixels[2] > 255)
pixels[2] = 255;
if (pixels[0] < 0)
pixels[0] = 0;
if (pixels[1] < 0)
pixels[1] = 0;
if (pixels[2] < 0)
pixels[2] = 0;
dataPtr[0] = Convert.ToByte(pixels[0]);
dataPtr[1] = Convert.ToByte(pixels[1]);
dataPtr[2] = Convert.ToByte(pixels[2]);
pixels[0] = 0;
pixels[1] = 0;
pixels[2] = 0;
dataPtr += nChan;
dataPtr2 += nChan2;
}
//.........这里部分代码省略.........
示例13: Enhancement
// Konstruktor
public Enhancement(Image<Bgr, Byte> image)
{
imageInput = image.Copy();
//imageTrafficsigns = imageBgr.Copy();
imageEnhanced = new Image<Bgr, Byte>(imageInput.Width, imageInput.Height);
}