I'm writing a script that takes a 2D matrix, finds the value of the centre element, and changes the other elements to this value. This is a test as I want to try this on images. I have:
A = [6,6,6,6,6,6; 6,5,5,5,5,6; 6,5,4,4,5,6; 6,5,4,4,5,6; 6,5,5,5,5,6; 6,6,6,6,6,6];
[x,y] = size(A);
x = x/2;
y = y/2;
cent = A(x,y);
flat = A./cent;
rec = 1./flat;
fixed = rec.*A;
When I run this, I get the right matrix (ie, a 6x6 matrix with all entries = 4). But when I plot the images, I'm getting this
On the left, the indexes are 6, 5, and 4, from out to in. On the right, the index is 4, but it has the same [RGB] as the pixels on the left with index = 5.
How can I fix this so the image on the right is navy?