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

4 次查看(过去 30 天)
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
  1 个评论
Rishi Balasubramanian
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.

请先登录,再进行评论。

回答(2 个)

Walter Roberson
Walter Roberson 2022-3-26
  1 个评论
Rishi Balasubramanian
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
Image Analyst 2022-3-27
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');
  7 个评论
Rishi Balasubramanian
Well, for the time being, I am using the rectangle function to create an oversized rectangle (3 bits width) with the location for bit flips and colored it red and increased the thickness to make it look like a really ugly red blop on the approximate error locations.
That's what I could muster. This is not for the users, but for my own reference for debugging. Just wanted to see approximately where the flips are happening instead of stopping the code and getting into the array in the workspace every now and then.
Now that I have you here, I have another question pposted regarding communications toolbox - https://www.mathworks.com/matlabcentral/answers/1690395-bch-encoder-error-locations?s_tid=srchtitle
Think you could also help with this?
Walter Roberson
Walter Roberson 2022-4-7
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by