matlab读取图像并转化为灰度图像

image = imread('C:\Users\Administrator\Desktop\图像降噪\src\original image\100.png');
image = rgb2gray(image);
image = imread('C:\Users\Administrator\Desktop\图像降噪\src\original image\1.bmp');
image = rgb2gray(image);
//% figure ,imshow(image);
//% dlmwrite('filename.txt', image, ',', 0, 0)
//% image = image';
figure ,imshow(image);
fid  = fopen('exp.txt','w');    fprintf(fid,'%x ',image);    fclose(fid); //%将图像iamge按照十六进制写入exp.txt 文件
fid1 = fopen('exp.txt','r');  varargout = fscanf(fid1, '%x',[256,256]);    fclose (fid1);    
varargout =  uint8(round(varargout))                      //%将读取的图像double类型转换为uint8
figure,imshow(varargout),title('show varargout');
fid2 = fopen('exp1.txt','w');   fprintf(fid2,'%d ',image);   fclose(fid2); //%将图像iamge按照十  进制写入exp1.txt文件
A =load('exp1.txt');                                                       //%读取exp.txt数据
image2 = zeros(256,256,'uint8');
for i = 1 : 256
    for j = 1 : 256
        image2(j,i) = A((i-1)*256+j);                                      //%读取一维数组1x65535 到矩阵【256 256】
    end
end
figure,imshow(image2),title('show image2');


最新文章

  1. duplicate symbols for architecture arm64 after xCode 8.0 update
  2. 使用jQuery的animate方法制作滑动菜单
  3. 【原】移动web页面使用字体的思考
  4. Software Development Engineer - Database Services
  5. 【转】UTF-8汉字正则表达式
  6. 设计模式之Singleton
  7. 向JS对象添加和删除事件
  8. JAVA获取两个List<String>中不同的数据
  9. C++11静态assert
  10. 关于Linux的10个核心面试问题与答案
  11. java_文件类
  12. proxy代理类
  13. DEDE首页调用{dede:field.content/}
  14. $(function(){})与(function($){....})(jQuery)的区别
  15. 3DMax的OFusion插件的使用问题
  16. 关于乱序(shuffle)与随机采样(sample)的一点探究
  17. EurekaClient项目启动报错Invocation of destroy method failed on bean with name 'scopedTarget.eurekaClient': org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'e
  18. 为什么CentOS7中找不到mysql服务,并且还找不到mysql.sock?
  19. Spring Aop实例@Aspect、@Before、@AfterReturning@Around 注解方式配置
  20. layui框架

热门文章

  1. archlinux下wifi-menu显示连接超时
  2. 十六进制字节 & 十六进制转二进制
  3. Win7下安装Apache+PHP+phpMyAdmin+wordpress+drupal+discuz
  4. solrj-WiKi
  5. 机顶盒Demux
  6. Android adb not responsing
  7. ios菜鸟总结2
  8. Java Script基础(一)
  9. CentOS7,Firewalld防火墙使用方法
  10. jQuery选择器之表单对象属性过滤选择器Demo