开发者

to replace black portion of an image, with any other image: in matlab

开发者 https://www.devze.com 2023-04-12 08:01 出处:网络
i have an image named imageA...imageA has some portion colored black. now i want to replace this Black portion of the imageA w开发者_运维知识库ith the pixels of imageB , in such a way thatlocation of

i have an image named imageA...imageA has some portion colored black. now i want to replace this Black portion of the imageA w开发者_运维知识库ith the pixels of imageB , in such a way that location of portion is same in other image.

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 .


Use Logical Indexing.

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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消