フィルターのクリア

problem displaying a satellite image

3 ビュー (過去 30 日間)
dakhli mohamed
dakhli mohamed 2019 年 1 月 10 日
コメント済み: Image Analyst 2019 年 1 月 11 日
Hello
I have a problem displaying a satellite image. I want to go from a grayscale image to a color image, and more precisely the zonne that has black pixels, I want to make it red (image attached).

採用された回答

Image Analyst
Image Analyst 2019 年 1 月 11 日
That's not a gray scale image you attached, it's an RGB image. So try this
rgbImage = imread('C1fig.jpg');
whos rgbImage
subplot(2, 1, 1);
imshow(rgbImage);
title('Original RGB image C1fig.jpg');
axis('on', 'image');
impixelinfo
mask = rgbImage(:, :, 1) == 0;
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
redChannel(mask) = 255;
greenChannel(mask) = 0;
blueChannel(mask) = 0;
% Recombine separate color channels into a single, true color RGB image.
rgbImage = cat(3, redChannel, greenChannel, blueChannel);
subplot(2, 1, 2);
imshow(rgbImage);
axis('on', 'image');
impixelinfo
title('Altered RGB image');
0000 Screenshot.png
If it really is a gray scale image, you can try this:
grayImage = imread('C1fig.jpg');
if ndims(grayImage) == 3;
grayImage = rgb2gray(grayImage);
end
whos grayImage
subplot(2, 1, 1);
imshow(grayImage);
title('Original image C1fig.jpg');
axis('on', 'image');
impixelinfo
mask = grayImage == 0;
% Initialize the individual red, green, and blue color channels.
redChannel = grayImage;
greenChannel = grayImage;
blueChannel = grayImage;
redChannel(mask) = 255;
greenChannel(mask) = 0;
blueChannel(mask) = 0;
% Recombine separate color channels into a single, true color RGB image.
rgbImage = cat(3, redChannel, greenChannel, blueChannel);
subplot(2, 1, 2);
imshow(rgbImage);
axis('on', 'image');
impixelinfo
title('Altered RGB image');
  2 件のコメント
dakhli mohamed
dakhli mohamed 2019 年 1 月 11 日
thank you so much
please another question
if I want the white part will be it red, that line of code I modify?
and thank you for your help
Image Analyst
Image Analyst 2019 年 1 月 11 日
If white is more than 250 or so, do this:
mask = grayImage >= 250;

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by