Index and RGB problems
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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;
subplot(1,2,1);
imagesc(A);
subplot(1,2,2);
imagesc(fixed);
---
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?
0 Kommentare
Antworten (1)
Amal George M
am 30 Dez. 2019
'imagesc' tries to map the 'C' matrix values to the colormap. If no scale is specified the minimum value will be mapped to the bluish end and the maximum value to the yellowish end. But, if the input has only one distinct input, the value will be something in the middle (greenish). This is the case here.
To map with a known color limit we can specify the limits:
imagesc(fixed,[4,6]);
0 Kommentare
Siehe auch
Kategorien
Mehr zu Blue finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!