zoukankan      html  css  js  c++  java
  • MATLAB学习(3)

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

    image = imread('C:UsersAdministratorDesktop图像降噪srcoriginal image100.png');
    image = rgb2gray(image);
    image = imread('C:UsersAdministratorDesktop图像降噪srcoriginal image1.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');
    
    

    
  • 相关阅读:
    HDU
    矩形嵌套(DP)
    HDU
    HDU-1003 Max Sum
    Manacher算法—最长回文串
    Codeforces Round #460 (Div. 2) A B C D
    HDU 4540 威威猫系列故事——打地鼠 (简单DP)
    UVA 129 Krypton Factor(DFS 回溯)
    Codeforces 918A Eleven 918B Radio Station
    挑战程序设计竞赛(第2版)第112页勘误
  • 原文地址:https://www.cnblogs.com/yxwkf/p/3901492.html
Copyright © 2011-2022 走看看