Replace elements in binary matrix

2 views (last 30 days)
Abdul Salam
Abdul Salam on 29 Jun 2019
Commented: Abdul Salam on 29 Jun 2019
I have a binary image and want to replace all the zeroes with 1s and all the 1s with zeroes. ( so that the binary image is totally opposite to original image). How can i do that?

Accepted Answer

Michal
Michal on 29 Jun 2019
Edited: Michal on 29 Jun 2019
% B original binary matrix
% B_ new binary matrix
B_ = ~B;

More Answers (1)

Walter Roberson
Walter Roberson on 29 Jun 2019
B_ = imcomplement(B);

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by