本文整理汇总了C#中Image.Sobel方法的典型用法代码示例。如果您正苦于以下问题:C# Image.Sobel方法的具体用法?C# Image.Sobel怎么用?C# Image.Sobel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image
的用法示例。
在下文中一共展示了Image.Sobel方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public void Run()
{
base.Output = new cImage(base.Input, false);
for (int IdxChannel = 0; IdxChannel < base.ListChannelsToBeProcessed.Count; IdxChannel++)
{
int CurrentChannel = base.ListChannelsToBeProcessed[IdxChannel];
Image<Gray, float> inputImage = new Image<Gray, float>(Input.Width, Input.Height);
for (int j = 0; j < Input.Height; j++)
for (int i = 0; i < Input.Width; i++)
inputImage.Data[j, i, 0] = Input.SingleChannelImage[CurrentChannel].Data[i + j * Input.Width];
Image<Gray, float> ProcessedImage = new Image<Gray, float>(inputImage.Width, inputImage.Height);
ProcessedImage = inputImage.Sobel(this.X_Order, this.Y_Order, this.Aperture);
this.Output.SingleChannelImage[IdxChannel].SetNewDataFromOpenCV(ProcessedImage);
}
return;
}
示例2: TestGetModuleInfo
public void TestGetModuleInfo()
{
Image<Bgr, Byte> img = new Image<Bgr, byte>(200, 100);
img.Sobel(1, 0, 3);
String plugin, module;
Util.GetModuleInfo(out plugin, out module);
}
示例3: _testMorphological
private Image<Gray, Single> _testMorphological(Image<Gray, Single> img, int threshold, int maxGrayVal, int closingIteration, int cols, int rows, int anchorX, int anchorY, int shape)
{
img = img.Sobel(0, 1, 3);
StructuringElementEx element = new StructuringElementEx(cols, rows, anchorX, anchorY, Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_RECT); ;
if (shape == 1)
element = new StructuringElementEx(cols, rows, anchorX, anchorY, Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_CROSS);
else if (shape == 2)
element = new StructuringElementEx(cols, rows, anchorX, anchorY, Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_ELLIPSE);
img = img.MorphologyEx(element, Emgu.CV.CvEnum.CV_MORPH_OP.CV_MOP_CLOSE, closingIteration);
img = img.Rotate(90.0, new Gray(255), false);
img = img.MorphologyEx(element, Emgu.CV.CvEnum.CV_MORPH_OP.CV_MOP_CLOSE, closingIteration);
img = img.Rotate(-90.0, new Gray(255), false);
if (threshold >= 0 && threshold <= maxGrayVal)
{
img = img.ThresholdBinary(new Gray(threshold), new Gray(255));
}
else
{
MessageBox.Show("Threshold is not appropriate, please choose another!");
}
return img;
}
示例4: _testSobelParameters
public void _testSobelParameters(Image<Gray, Single> img, int threshold, int maxGrayVal, int closingIteration, int cols, int rows, int anchorX, int anchorY, int shape)
{
int xOrder = 0, yOrder = 0, appetureSize = 1;
for (appetureSize = 3; appetureSize < 8; appetureSize += 2)
{
for (xOrder = 0; xOrder < appetureSize-1; xOrder++)
for (yOrder = 0; yOrder < appetureSize-1; yOrder++)
{
img = img.Sobel(xOrder, yOrder, appetureSize);
StructuringElementEx element;
if (shape == 0)
element = new StructuringElementEx(cols, rows, anchorX, anchorY, Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_RECT);
else if (shape == 1)
element = new StructuringElementEx(cols, rows, anchorX, anchorY, Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_CROSS);
else
element = new StructuringElementEx(cols, rows, anchorX, anchorY, Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_ELLIPSE);
img = img.MorphologyEx(element, Emgu.CV.CvEnum.CV_MORPH_OP.CV_MOP_CLOSE, closingIteration);
img = img.Rotate(90.0, new Gray(255), false);
img = img.MorphologyEx(element, Emgu.CV.CvEnum.CV_MORPH_OP.CV_MOP_CLOSE, closingIteration);
img = img.Rotate(-90.0, new Gray(255), false);
if (threshold >= 0 && threshold <= maxGrayVal)
{
img = img.ThresholdBinary(new Gray(threshold), new Gray(255));
}
else
{
MessageBox.Show("Threshold is not appropriate, please choose another!");
}
img.Bitmap.Save(@"Sobel\" + xOrder + " " + yOrder + " " + appetureSize + ".png");
}
}
}
示例5: _imageProcessing
/// <summary>
///
/// </summary>
/// <param name="img">Input Image</param>
/// <param name="threshold">Threshold value (with 8-bit image is from 0 to 255)</param>
/// <param name="maxGrayVal">Maximum Gray Value</param>
/// <param name="closingIteration">number of Iterations</param>
/// <returns>Processed Image</returns>
public Image<Gray, Single> _imageProcessing(Image<Gray, Single> img, int threshold, int maxGrayVal, int closingIteration)
{
img = img.Sobel(0, 1, 3);
StructuringElementEx element = new StructuringElementEx(3, 3, -1, -1, Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_ELLIPSE);
img = img.MorphologyEx(element, Emgu.CV.CvEnum.CV_MORPH_OP.CV_MOP_CLOSE, closingIteration);
img = img.Rotate(-90.0, new Gray(255), false);
img = img.MorphologyEx(element, Emgu.CV.CvEnum.CV_MORPH_OP.CV_MOP_CLOSE, closingIteration);
img = img.Rotate(90.0, new Gray(255), false);
if (threshold >= 0 && threshold <= maxGrayVal)
{
img = img.ThresholdBinary(new Gray(threshold), new Gray(maxGrayVal));
}
else
{
//MessageBox.Show("Threshold is not appropriate, please choose another!");
throw new ArgumentOutOfRangeException("Threshold is not appropriate, please choose another threshold value!");
}
return img;
}
示例6: testClosingParameters
public void testClosingParameters(Image<Gray, Single> inputImg)
{
int rows, colums, anchorX, anchorY, shape, closingIteration, threshold;
int count = 1;
Image<Gray, float> img = inputImg;
for (closingIteration = 6; closingIteration < 7; closingIteration++)
{
for (shape = 0; shape < 1; shape++)
{
for (rows = 5; rows < 7; rows++)
for (colums = 5; colums < 7; colums++)
{
for (anchorX = 0; anchorX < colums; anchorX++)
for (anchorY = 0; anchorY < rows; anchorY++)
{
for (threshold = 80; threshold < 180; threshold += 20)
{
img = inputImg.Sobel(0, 1, 3);
img = inputImg.Sobel(1, 0, 3);
StructuringElementEx element = new StructuringElementEx(colums, rows, anchorX, anchorY, Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_RECT); ;
if (shape == 1)
element = new StructuringElementEx(colums, rows, anchorX, anchorY, Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_CROSS);
else if (shape == 2)
element = new StructuringElementEx(colums, rows, anchorX, anchorY, Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_ELLIPSE);
img = img.MorphologyEx(element, Emgu.CV.CvEnum.CV_MORPH_OP.CV_MOP_CLOSE, closingIteration);
img = img.Rotate(90.0, new Gray(255), false);
img = img.MorphologyEx(element, Emgu.CV.CvEnum.CV_MORPH_OP.CV_MOP_CLOSE, closingIteration);
img = img.Rotate(-90.0, new Gray(255), false);
if (threshold >= 0 && threshold <= 255)
{
img = img.ThresholdBinary(new Gray(threshold), new Gray(255));
}
else
{
MessageBox.Show("Threshold is not appropriate, please choose another!");
}
string str_shape;
if (shape == 0)
str_shape = "RECTANGLE";
else if (shape == 1)
str_shape = "CROSS";
else str_shape = "ELLIPSE";
img.Bitmap.Save(@"Result\" + closingIteration + "_" + str_shape + "_" + rows + "_" + colums + "_" + anchorX + "_" + anchorY + "_" + threshold + ".bmp");
count++;
}
}
}
}
}
MessageBox.Show("Done " + count + " images saved!");
}
示例7: _imageProcessing
/// <summary>
///
/// </summary>
/// <param name="img">Input Image</param>
/// <param name="threshold">Threshold value (with 8-bit image is from 0 to 255)</param>
/// <param name="maxGrayVal">Maximum Gray Value</param>
/// <param name="closingIteration">number of Iterations</param>
/// <returns></returns>
private Image<Gray, Single> _imageProcessing(Image<Gray, Single> img, int threshold, int maxGrayVal, int closingIteration)
{
img = img.Sobel(0, 1, 4);
StructuringElementEx element = new StructuringElementEx(4, 4, 1, 1, Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_RECT);
//MessageBox.Show((int)Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_ELLIPSE + "");
img = img.MorphologyEx(element, Emgu.CV.CvEnum.CV_MORPH_OP.CV_MOP_CLOSE, closingIteration);
img = img.Rotate(90.0, new Gray(maxGrayValue), false);
img = img.MorphologyEx(element, Emgu.CV.CvEnum.CV_MORPH_OP.CV_MOP_CLOSE, closingIteration);
img = img.Rotate(-90.0, new Gray(maxGrayValue), false);
if (threshold >= 0 && threshold <= maxGrayVal)
{
img = img.ThresholdBinary(new Gray(threshold), new Gray(maxGrayValue));
}
else
{
MessageBox.Show("Threshold is not appropriate, please choose another!");
}
return img;
}
示例8: sobel_Filter
private Image<Gray, Single> sobel_Filter(Image<Gray, Single> img)
{
int xOrder = Int32.Parse(txtXorder.Text), yOrder = Int32.Parse(txtYorder.Text),
appetureSize = Int32.Parse(txtAppetureSize.Text);
//img = img.Sobel(0, 1, 5);
//Image<Gray, float> horImg, verImg;
//horImg = img.Sobel(xOrder, yOrder, appetureSize);
//verImg = img.Sobel(yOrder,xOrder, appetureSize);
//img = horImg + verImg;
var blurImg = img.SmoothGaussian(3, 3, 34.3, 45.3);
var mask = img - blurImg;
mask *= 20;
img += mask;
img = img.SmoothBilatral(7, 255, 34);
img._ThresholdBinaryInv(new Gray(16), new Gray(255));
img = img.Sobel(xOrder, yOrder, appetureSize);
return img;
}