Setting certain pixels in a grayscale image to RGB (red) for MIP
5 ビュー (過去 30 日間)
古いコメントを表示
Hey again. I have a grayscale image and would like to highlight certain pixels by setting them to red, e.g.
save_array = image;
save_array(Omega==1) = %RED
Is there an easy way to do this? I will be taking the image (3D array), calculating the MIP (max intensity projection) by
mip_final = max(save_array, [], 3);
and would then like the red pixels to appear on the MIP (2D). So if a pixel is red anywhere in the z-dimension, it will appear red in the 2D MIP
0 件のコメント
回答 (2 件)
Image Analyst
2018 年 8 月 6 日
Try this:
redChannel = grayImage; % Initialize
greenChannel = grayImage; % Initialize channel for green and blue channel.
redChannel(Omega) = 255;
greenChannel(Omega) = 0;
rgbImage = cat(3, redChannel, greenChannel, greenChannel);
5 件のコメント
Image Analyst
2018 年 8 月 7 日
OK, so you have a volumetric image, like from CT or MRI. So just mask the image
masked3DImage = grayImage3d; % Initialize
masked3DImage(~Omega) = -inf; % Mask
masked3DImage = max(masked3DImage , [], 3); % Do MIP
masked3DImage(~Omega) = 0; % minus infinity set to zero or whatever value you want outside of the mask.
Thorsten
2018 年 8 月 8 日
From the above discussion, I came up with this solution:
% fake some data
X = rand(10, 10, 23);
N = prod(size(X));
idx = randi(N, 1, round(0.01*N)); % 1% of all pixels are 1
X(idx) = 1;
Omega = X == 1; % find the values that are 1 in X
idx = sum(Omega, 3) > 0; % project to a 2D binary image
MIP = max(X, [], 3);
% create a color image from MIP
R = MIP; R(idx) = 1;
G = MIP; G(idx) = 0;
B = MIP; B(idx) = 0;
I = cat(3, R, G, B);
imshow(I)
8 件のコメント
Thorsten
2018 年 8 月 9 日
編集済み: Thorsten
2018 年 8 月 9 日
You can visualize only the red blocks using plotcube from the FileExchange:
X = rand(10, 10, 23);
% X = rand(3000,1000,600);
N = prod(size(X));
idx = randi(N, 1, round(0.01*N)); % 1% of all pixels are 1
X(idx) = 1;
[x, y, z] = ind2sub(size(X), idx);
for i = 1:numel(x)
plotcube([1, 1, 1], [x(i) y(i) z(i)], .8, 'r')
if i == 1, hold on, end
end
axis equal
grid on
参考
カテゴリ
Help Center および File Exchange で Display and Exploration についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!