setting range for pixel intensity

1 回表示 (過去 30 日間)
monika  SINGH
monika SINGH 2019 年 4 月 11 日
コメント済み: monika SINGH 2019 年 4 月 12 日
i am having a gray level image, i want to set range like if x(i,j)=183 to 215 it will have some value
c programming for this would be like
x[i,j]=pixel intensity
for(i=0;i<=n;i++)
{
for(j=0;j<=n;j++)
{
if(x[i,j]=183||x[ij]=215
{green color}
else
{red}
end
}}
how i would show this in matlab

回答 (1 件)

Guillaume
Guillaume 2019 年 4 月 11 日
編集済み: Guillaume 2019 年 4 月 11 日
You have to decide if your image is greyscale or colour. You obviously can't set a pixel to green in a greyscale image without first converting it to truecolour. In any case, your if/else would produce a binary image which by default is displayed in black and white.
Anyway, in matlab you wouldn't use a loop for this
%greyimage: your 2d matrix of the image, most likely of type uint8 if you're using intensities 183 and 215
bwimage = ismember(greyimage, [183, 215]);
%bwimage is a logical array the same size as the image with true (1) when the pixel has value 183 or 215 and false (0) otherwise
  2 件のコメント
Image Analyst
Image Analyst 2019 年 4 月 11 日
Then
greyImage(bwimage) = someValue; % Set to whatever you want.
Do it one color channel at a time if you have a color image.
monika  SINGH
monika SINGH 2019 年 4 月 12 日
sir i did not understand what exactly you want to convey?

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

カテゴリ

Help Center および File ExchangeModify Image Colors についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by