【问题标题】:logical and uint8 comparison逻辑和 uint8 比较
【发布时间】:2013-09-21 20:04:02
【问题描述】:

我有一张数据类型为logical 的图像。当我将其转换为 uint8 时,我得到一个空白图像。我正在尝试将此图像与另一张图像进行比较,它们的数据类型必须相同。

如果这不起作用,我可以转换成哪些数据类型而不会得到空白结果。

我有两张图片,一张类型为logical,另一张类型为uint8。如果上述方法不起作用,我可以转换成什么相同的数据类型以便能够将它们一起比较?

【问题讨论】:

  • 尝试将矩阵乘以 255。这样 0->0, 1->255。

标签: matlab type-conversion image-comparison


【解决方案1】:

转换工作得很好。当您显示uint8 图像时,最亮的值为 255,但在您的图像中,强度仅上升到 1。如果您查看矩阵,它不是空白的。您可以以双重格式显示图像以查看掩码是否仍然存在,或者将转换后的图像乘以 255(或其他)。

【讨论】:

    【解决方案2】:

    例子:

    bw = rand(5)<0.5;    % some logical image mask
    
    iptsetpref('ImshowInitialMagnification','fit')
    
    % display logical image
    imshow(bw)
    
    % convert to UINT8 and multiply by 255
    imshow(uint8(bw)*255)
    
    % convert to UINT8 and specify appropriate display range
    % (empty will compute it from data: [min max] == [0 1])
    imshow(uint8(bw), [])
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-24
      • 1970-01-01
      • 2012-07-16
      • 2010-12-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多