您好我有一张使用imagesc(img)
生成的图片。图像包含0到18之间的值。我想在matlab中以这样的方式应用阈值
for 0<img<5----> no change
for 6<img<8----> increase pixel value by 15
for 10<img<12---> increase by 10
for 12<img<15--> increase by 8
for 15<img<18---> increase by 6
提前致谢
答案 0 :(得分:2)
您只需要根据条件索引img变量:
img(img > 15 & img < 18) = img(img > 15 & img < 18) + 6;
img(img > 12 & img < 15) = img(img > 12 & img < 15) + 8;
img(img > 10 & img < 12) = img(img > 10 & img < 12) + 10;
img(img > 6 & img < 8) = img(img > 6 & img < 8) + 15;