如何将特定索引处矩阵的像素值设置为具有相同索引的不同矩阵的像素值?
How to set pixel values of a matrix at specific indexes to pixel values of a different matrix with the same indexes?
我想做的是用矩阵运算对图像进行阈值处理,而不是将阈值结果设置为固定值,比如 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 < 100) = thirdImage(firstImage < 100) * 10;
即就像你索引 secondImage
,索引 thirdimage
一样。
我想做的是用矩阵运算对图像进行阈值处理,而不是将阈值结果设置为固定值,比如 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 < 100) = thirdImage(firstImage < 100) * 10;
即就像你索引 secondImage
,索引 thirdimage
一样。