Index and RGB problems
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Amal George M
2019 年 12 月 30 日
'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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Blue についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!