フィルターのクリア

How to make triangle for a synthetic image in gray scale

9 ビュー (過去 30 日間)
Tabish Raza
Tabish Raza 2013 年 3 月 18 日
編集済み: Walter Roberson 2017 年 2 月 18 日
Helo me trying to make a synthetic image in gray scale with some rectangular shape and triangle but have trouble how to make triangle.

採用された回答

Image Analyst
Image Analyst 2013 年 3 月 19 日
Try this:
rows = 240;
columns = 320;
grayImage = zeros(rows, columns, 'uint8');
xCoords = [100 200 300];
yCoords = [80 160 80];
mask = poly2mask(xCoords, yCoords, rows, columns);
grayImage(mask) = 150; % or whatever value you want.
imshow(grayImage);

その他の回答 (3 件)

Walter Roberson
Walter Roberson 2013 年 3 月 19 日
poly2roi()

Benhassine Nasser edinne
Benhassine Nasser edinne 2017 年 2 月 18 日
thank you very mutch

Benhassine Nasser edinne
Benhassine Nasser edinne 2017 年 2 月 18 日
編集済み: Walter Roberson 2017 年 2 月 18 日
you can make this i.e
fname = uigetfile('*.*'); % gray scale image
Io = imread(fname);
I=Io;
xCoords = [200 512 512];
yCoords = [512 128 512];
mask = poly2mask(xCoords, yCoords, size(I,1), size(I,2));
I(mask) = 0;
Iresult=I;
subplot(1,3,1);imshow(Io) ;title('original image');
subplot(1,3,2);imshow(mask) ;title('triangl mask');
subplot(1,3,3);imshow(Iresult) ;title('Result image');

Community Treasure Hunt

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

Start Hunting!

Translated by