0
변환 이미지를 binary, binary_inverse 등으로 변환하기위한 C# 프로그램을 만들었습니다.내 emgu cv (C#) 코드는 하나의 이미지에서만 작동하며 다른 이미지에서는 작동하지 않습니다.
어쨌든 이미지는 내가 처음에는 사용했지만 다른 이미지를 시도 할 때마다 부숴졌습니다.
누군가가 문제를 찾도록 도와 주시면 감사하겠습니다.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Emgu.CV;
using Emgu.CV.Structure;
using Emgu.CV.Util;
using Emgu.CV.CvEnum;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
resetui();
}
private Image<Bgr, Byte> ori;
private Image<Gray, Byte> edited;
private void button3_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
pB.ImageLocation = openFileDialog1.FileName ;
ori = new Image <Bgr,Byte> (openFileDialog1.FileName) ;
edited = new Image<Gray, Byte>(ori.Width, ori.Height) ;
}
}
private void button2_Click(object sender, EventArgs e)
{
CvInvoke.cvCvtColor(ori, edited, COLOR_CONVERSION.CV_BGR2GRAY);
pB.Image = edited.ToBitmap();
groupBox1.Enabled = true;
}
private void button1_Click(object sender, EventArgs e)
{
pB.Image = ori.ToBitmap();
groupBox1.Enabled = false;
button1.Enabled = false;
button2.Enabled = true;
}
private void resetui()
{
button1.Enabled = true;
button2.Enabled = true;
groupBox1.Enabled = false;
}
private void CalcThresh()
{
if (cB.SelectedIndex == 0)
{
pB.Image = edited.ToBitmap();
return;
}
Image<Gray, byte> temp = new Image<Gray, Byte>(edited.Height, edited.Width);
double threshold = tB.Value;
double maxval = (double) max.Value;
THRESH mode = THRESH.CV_THRESH_BINARY;
switch (cB.SelectedIndex)
{
case 1:
mode = THRESH.CV_THRESH_BINARY ;
break ;
case 2:
mode = THRESH.CV_THRESH_BINARY_INV ; break ;
case 3:
mode = THRESH.CV_THRESH_TOZERO; break ;
case 4 :
mode = THRESH.CV_THRESH_TOZERO_INV; break ;
case 5:
mode = THRESH.CV_THRESH_TRUNC; break ;
}
CvInvoke.cvThreshold(edited, temp, threshold, maxval, mode);
pB.Image = temp.ToBitmap();
}
private void cB_SelectedIndexChanged(object sender, EventArgs e)
{
CalcThresh();
}
private void max_ValueChanged(object sender, EventArgs e)
{
CalcThresh();
}
private void tB_Scroll(object sender, EventArgs e)
{
CalcThresh();
}
}
}
는 Heres는 첫 번째 이미지는 내가
그것은 예를 들어 다음과 같이 잘 작동 사용 :
을하지만 난이 모드를 포착 할 때마다 다른 이미지가 충돌 :
내 프로그램을 만든 그림이 하나가 추락 :
이 같은 양식의 deisgn 보이는 방법 :
임은 시험이 공부 그렇다면 누군가가 내가 정말로 문제를 찾도록 도울 수있다.
appr 그것을 eciate하십시오. 내가이 할 수
Image<Gray, byte> temp = new Image<Gray, byte>(edited.Width, edited.Height);
많은 이미지로 테스트하지만, 그것은 단지 내가 사용에 계속 오류가 첫 번째 이미지에서 작동이와
:
들으 – Johnny21