【问题标题】:How can I decrease a picture's brightness levels in MATLAB?如何在 MATLAB 中降低图片的亮度级别?
【发布时间】:2011-07-13 00:02:19
【问题描述】:

如何在 MATLAB 中降低图片的亮度级别?例如从 256(在 8 位图片中)到 10?

【问题讨论】:

标签: matlab image-processing


【解决方案1】:

我会推荐以下代码,它可以更直接地完成您正在寻找的内容:

srcBitDepth = 8;
dstBitDepth = 2;

img = imread('cameraman.tif');
subplot(1,2,1); imshow(img,[]);

img = bitshift(img, dstBitDepth-srcBitDepth);
subplot(1,2,2); imshow(img,[]);

结果如下:

注意从原始 8 位图像到 2 位图像的位减少。

【讨论】:

    【解决方案2】:

    要将图像从X 灰度级转换为Y 灰度级的图像,您可以这样写

    modifiedImage = round( double(rawImage)/X * Y);
    

    然后您可以将modifiedImage 转换为您选择的整数格式,例如uint8

    modifiedImage = uint8(modifiedImage);
    

    【讨论】:

      猜你喜欢
      • 2012-07-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-21
      相关资源
      最近更新 更多