function IM2BW()
%close all;
%clear all;
%I=imread('D:\Documents\Pictures\YB4.bmp');
I=imread('D:\Documents\MATLAB\myAdd\test1.bmp');
I1=im2double(I); %将彩图序列变成双精度
I2=rgb2gray(I1); %将彩色图变成灰色图
[thr, sorh, keepapp]=ddencmp('den','wv',I2);
I3=wdencmp('gbl',I2,'sym4',2,thr,sorh,keepapp); %小波除噪
I4=medfilt2(I3,[7 7]); %中值滤波
I5=imresize(I4,1,'bicubic'); %图像大小
%BW5=edge(I5,'canny'); %用canny算子进行边缘检测
h=fspecial('gaussian',5);%高斯滤波
%if num>2
BW6=edge(I5,'zerocross',[ ],h); %zerocross图像边缘提取
%end
figure
title('二值图');
imshow(BW6);
saveas(gcf,'test1.jpg')
return
end
感觉问题不断啊。。。昨天才把矩阵运算的例子实验成功,可是换个程序就又出错了。。。。
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 pic1;
using MathWorks.MATLAB;
using MathWorks.MATLAB.NET.Arrays;
using MathWorks.MATLAB.NET.Utility;
using System.IO;
namespace picture1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
pic1.picClass1 pcl = new picClass1();
pcl.IM2BW();
String path = Directory.GetDirectoryRoot("E:");
//String []path = Directory.GetFiles("E:\\matlab\\");
path = path + "test1.jpg";
pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
pictureBox1.Image = Image.FromFile(path);
}
}
}
错误提示:
MATLAB编译图片:
1 个解决方案
#1
自己先顶一下,希望有高手可以指点一下。
#1
自己先顶一下,希望有高手可以指点一下。