zoukankan      html  css  js  c++  java
  • 【matlab】图像直方图

    使用imhist函数(要先用rgb2gray转化为灰度图像)

    利用matlab计算图像直方图函数为imhist() 
    具体用法: 
    imhist( i );直接显示图像i的灰度直方图; 
    imhist(i,n)n为指定灰度级显示直方图; 
    [count, x] = imhist( i ) 获取直方图信息,count为每一级灰度像素个数,x为灰度级,x也可以在imhist(i,x)中指定,可以通过stem(x,count)画相应直方图;

    imhist2.m文件:

    I = imread('E:workKodakgirl.jpg');
    I = rgb2gray(I);
    % imshow(i);
    % figure;
    imhist(I);
    % figure;
    %  imhist(i,32);
    figure;
    [count,x] = imhist(I,150);
    stem(x,count);

    imhist3.m文件:适当将其灰度增强,0.8亮,0.3暗

    I = imread('E:workKodakgirl.jpg'); 
    % imshow(I);
    % figure;
    [d1,d2,d3] = size(I); 
    if(d3 > 1) 
    I = rgb2gray(I);%如果是灰度图d3=1,就不用变换 
    end
    % [d1,d2,d3] = size(I);
    I = double(I) / 255; 
    I1 = uint8(255 * I * 0.8 + 0.5); %0.8可变,uint8意思是转换成8bit无符号整型
    imshow(I1);imwrite(I,'test.jpg')
  • 相关阅读:
    Linux服务器查看日志命令总结
    nginx高可用(5)
    nginx动静分离(4)
    nginx负载均衡(3)
    nginx反向代理(2)
    nginx安装及使用(1)
    Nginx 简易教程
    uiautomator2中文文档
    TKinter之输入框
    nginx解决反向代理session丢失问题
  • 原文地址:https://www.cnblogs.com/wxl845235800/p/7193054.html
Copyright © 2011-2022 走看看