本文介绍了用任何其他图像替换图像的黑色部分:在Matlab中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为imageA的图像... imageA的某些部分为黑色.现在,我想用imageB的像素替换imageA的黑色部分,以使该部分的位置在其他图像中相同.

i have an image named imageA...imageA has some portion colored black.now i want to replace this Black portion of the imageA with the pixels of imageB , in such a way that location of portion is same in other image.

就像imageA中的黑色像素的位置=(10,15)一样,该黑色像素应替换为imageB中的位置(10,15)的像素.

like if the position of black pixel in imageA=(10,15) , than this black pixel should be replaced with the pixel at the location (10,15) in imageB .

推荐答案

使用逻辑索引.

zeropixels = imageA == 0
imageA(zeropixels) = imageB(zeropixels)

您可能需要一些额外的错误检查代码,以确保逻辑矩阵zeropixels对于索引imageB是有效的.

You might need some extra error checking code to ensure that the logical matrix zeropixels is valid for indexing imageB.

这篇关于用任何其他图像替换图像的黑色部分:在Matlab中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 05:54