【问题标题】:How to set pixel values of a matrix at specific indexes to pixel values of a different matrix with the same indexes?如何将特定索引处矩阵的像素值设置为具有相同索引的不同矩阵的像素值?
【发布时间】:2018-06-26 17:50:11
【问题描述】:

我正在尝试使用矩阵运算对图像进行阈值处理,但不是将阈值结果设置为固定值,例如 256 或其他值,而是尝试将结果设置为等于像素值的计算来自另外两个相同大小的图像。所以,例如:

firstImage = img1;
secondImage = img2;
thirdImage = img3;
secondImage(firstImage < 100) = thirdImage(at the same indexes as where the thresholding condition holds true) .* 10;

MATLAB 通常会尝试将整个 thirdImage .* 10 相乘并保存,但我想要的只是那些匹配的特定像素以执行操作并覆盖 secondImage 中的相应值。

如何做到这一点?

【问题讨论】:

  • 你已经在问题中自己回答了:secondImage(firstImage&lt;100)=thirdImage(firstImage&lt;100)*10;
  • @SardarUsama 谢谢!如果您想将其写为完整评论,我可以将其标记为答案。

标签: matlab matrix image-thresholding


【解决方案1】:

你自己在这个问题中有点想通了:

secondImage(firstImage < 100) = thirdImage(firstImage < 100) * 10;

即就像你以同样的方式索引secondImage,索引thirdimage

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-12-06
    • 2014-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-05
    • 2013-03-28
    • 1970-01-01
    相关资源
    最近更新 更多