/// <summary> /// 適応型二値化 /// </summary> private void CreateAdaptBinaryImage() { try { if (this.FileName == null) { this.FileName = this.SelectImageFile(); } CvAdaptMethod adaptMethod = this.AdaptiveThresholdProperty.AdaptMethod; int blockSize = this.AdaptiveThresholdProperty.BlockSize; double param = this.AdaptiveThresholdProperty.Param; using (CvImage orgImage = new CvImage(this.FileName)) using (CvImage smoothImage = CvImgProc.AdaptiveThresdhold(orgImage, adaptMethod, blockSize, param)) using (MemoryStream stream = new MemoryStream()) { Bitmap bitmap = smoothImage.GetImageBmp(); if (bitmap == null) { MessageBox.Show("bitmap null."); return; } bitmap.Save(stream, ImageFormat.Bmp); // BitmapImageの作成(キャッシュを切る) BitmapImage bmpImage = new BitmapImage(); bmpImage.BeginInit(); bmpImage.CacheOption = BitmapCacheOption.OnLoad; bmpImage.CreateOptions = BitmapCreateOptions.None; bmpImage.StreamSource = stream; bmpImage.EndInit(); bmpImage.Freeze(); this.Image005.Source = bmpImage; bmpImage = null; } } catch (Exception ex) { throw ex; } }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null) { return(-1); } CvAdaptMethod valueCvSmoothType = (CvAdaptMethod)value; switch (valueCvSmoothType) { case CvAdaptMethod.EQUIVALENT: return(0); case CvAdaptMethod.GAUSSIAN: return(1); default: return(-1); } }