xxx

作者: 梦幽辰 | 来源:发表于2021-04-17 14:36 被阅读0次

    灰度阈值法分割

    clc;
    clear all;
    f=imread('E:\document\MATLAB\image\xxx2.png');
    f1=im2bw(f,91/255);
    f2=im2bw(f,140/255);
    f3=im2bw(f,120/255);
    f4=im2bw(f,56/255);
    subplot(2,2,1);imshow(f1);
    subplot(2,2,2);imshow(f2);
    subplot(2,2,3);imshow(f3);
    subplot(2,2,4);imshow(f4);
    
    image.png

    全局阈值分割

    clc;
    clear all;
    I=imread('E:\document\MATLAB\image\xxx2.png'); 
    subplot(1,2,1);
    imshow(I);
    level = graythresh(I);  %求取二值化的阈值
    BW = im2bw(I, level);   %按阈值进行二值化
    subplot(1,2,2);
    imshow(BW);
    
    image.png

    局部阈值分割

    clc;
    clear all;
    n=imread('E:\document\MATLAB\image\xxx2.png'); 
    f=rgb2gray(n);
    T = graythresh(f);                          % 自动获取阈值
    T = T*255;                                % 阈值在区间[0,1],需调整至[0,255]
    g = f>T;
    subplot(1,2,1);imshow(f);title('原图像');
    subplot(1,2,2);imshow(g);title(['阈值处理,阈值为' num2str(T)]);
    
    image.png

    相关文章

      网友评论

          本文标题:xxx

          本文链接:https://www.haomeiwen.com/subject/lpgulltx.html