# Change color of specific bits Imagesc(), Image()

8 views (last 30 days)
Rishi Balasubramanian on 26 Mar 2022
Commented: Walter Roberson on 7 Apr 2022
Hi,
I have a binary matrix, where my algorithm runs through to find inconsistencies and flip the respective bits as it goess row by row. I want to be able to show those specific bit changes in a different color to visually demonstrate the process. Is it possible?
Edit - I may have missed out a key point. I use imagesc() to show the entire array. In that figure, I want the bit change to be shown. Currently I am playing with casting a bit sized rectangle on the flip coordinates
Rishi Balasubramanian on 26 Mar 2022
For those bit flips, i flip it using the ~ operator, so I will be having the coordinates of the specific bit flips to begin with.

Walter Roberson on 26 Mar 2022
Rishi Balasubramanian on 27 Mar 2022
I may have missed out a key point. I use imagesc() to show the entire array. In that figure, I want the bit change to be shown. Currently I am playing with casting a bit sized rectangle on the flip coordinates

Image Analyst on 27 Mar 2022
I see you've added tags about images. So, see my attached demo about viewing bit planes. If you flipped a bit, you could have another logical matrix that keeps track of what pixels got their bits flipped, and then use imoverlay to display the flipped bits in color over the original.
rgbImage = imoverlay(originalMatrix, matrixOfFlippedBits, 'r');
imshow(rgbImage);
title('Flipped bits in red');
Walter Roberson on 7 Apr 2022
You have indicated that you have up to 10^9 rows. You are trying to represent those rows visually. I have pointed out that your display has only a small fraction of that resolution.
You could assign each bit to be a "summary" of a range of rows. For example you might decide:
• first color: no errors in this range, values were majority 0
• second color: no errors in this range, values were majority 1
• third color: errors have occurred in this range, the majority of them flipped 0 to 1
• fourth color: errors have occurred in this range, the majority of them flipped 1 to 0
You do not need to keep track of all of the bits in a block: you could keep track of the number of 0's and 1's and 0-1 errors and 1-0 errors.
You could even animate, keeping statistics over a range of time; decrement by totals counters by the stored numbers from N states ago to "reverse" the effect of that previous state.

### Categories

Find more on Images in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!