【问题标题】:Contrast Stretching for colore images with MATLAB使用 MATLAB 对彩色图像进行对比度拉伸
【发布时间】:2017-11-25 01:49:07
【问题描述】:

我在 matlab 中工作,我想对灰度图像和 RGB 图像应用对比度拉伸, 所以对于灰度我已经尝试过这个并且它有效

      clear all;
      clc;
      itemp = imread('cameraman.tif'); %read the image
      i = itemp(:,:,1);
        rtemp = min(i);         % find the min. value of pixels in all the 
       columns (row vector)
        rmin = min(rtemp);      % find the min. value of pixel in the image
        rtemp = max(i);         % find the max. value of pixels in all the 
       columns (row vector)
       rmax = max(rtemp);      % find the max. value of pixel in the image
       m = 255/(rmax - rmin);  % find the slope of line joining point 
      (0,255) to (rmin,rmax)
       c = 255 - m*rmax;       % find the intercept of the straight line 
       with the axis
       i_new = m*i + c;        % transform the image according to new slope
       figure,imshow(i);       % display original image
       figure,imshow(i_new);   % display transformed image

这是灰度图像,

问题是我不知道如何处理 RGB 图像 任何想法?如何实施? 谢谢你:)

【问题讨论】:

    标签: matlab


    【解决方案1】:

    函数stretchlim (reference) 对您的目的有用吗?

    找到对比度拉伸图像的限制。

    Low_High = stretchlim(RGB,Tol) 返回 Low_High,一个二元素向量 指定可以使用的下限和上限的像素值 用于对比度拉伸真彩色图像 RGB。

    img = imread('myimg.png');
    lohi = stretchlim(img,[0.2 0.8]);
    

    【讨论】:

      【解决方案2】:

      如果你写

      rmin = min(i(:));
      

      然后它计算i 中所有值的最小值。这也适用于 RGB 图像,它只是沿 3 维具有 3 个值的 3D 矩阵。

      您的其余代码也直接应用于此类图像。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-05-31
        • 1970-01-01
        • 1970-01-01
        • 2019-02-05
        • 1970-01-01
        • 2013-02-28
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多