フィルターのクリア

How can i color the pixels in red?

4 ビュー (過去 30 日間)
Pamela Paolo
Pamela Paolo 2012 年 12 月 5 日
Hi, for an image I, I want to color in red the pixels having the coordinates x and y stored in the matrix xy
[L C]=size(I);
xy=[x y];
thanks in advance
  1 件のコメント
Walter Roberson
Walter Roberson 2012 年 12 月 5 日
What kind of image is it? RGB or pseudocolor? If it is pseudocolor is it acceptable that it be converted to RGB using the current colormap ?

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

回答 (1 件)

Image Analyst
Image Analyst 2012 年 12 月 5 日
Try this, assuming you want to set pixels in an RGB image to red.
for k = 1 : length(xy)
row = int32(xy(k,1));
col = int32(xy(k,2));
rgbImage(row, col, 1) = 255;
rgbImage(row, col, 2) = 0;
rgbImage(row, col, 3) = 0;
end
If you have a monochrome image, you'll first have to convert it to an rgb image:
rgbImage = cat(3, grayImage, grayImage, grayImage);
% After that, then it's the same loop as above.
for k = 1 : length(xy)
row = int32(xy(k,1));
col = int32(xy(k,2));
rgbImage(row, col, 1) = 255;
rgbImage(row, col, 2) = 0;
rgbImage(row, col, 3) = 0;
end

カテゴリ

Help Center および File ExchangeRed についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by