How to make a grid in binary image

8 ビュー (過去 30 日間)
piyanat chansong
piyanat chansong 2016 年 5 月 9 日
コメント済み: Image Analyst 2016 年 5 月 9 日
I would like to create a grid on binary image, how can i write a matlab code? please help me out

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 5 月 9 日
CM = [186 186 186; 255 255 255] / 255;
image(YourBinaryMatrix + 1);
colormap(CM);
xt = 1 : size(YourBinaryMatrix, 2)-1;
yt = 1 : size(YourBinaryMatrix, 1)-1;
set(gca, 'xgrid', 'on', 'ygrid', 'on', 'xtick', 1/2+xt, 'ytick', 1/2+yt, 'xticklabel', [], 'yticklabel', [])
  4 件のコメント
Walter Roberson
Walter Roberson 2016 年 5 月 9 日
You can use
set(gca, 'Xcolor', 'w', 'Ycolor', w')
to set the grid lines to white.
However, if you want the grid lines to automatically contrast with the adjacent information, then you need to draw each line individually.
If you are using R2014b or later, you will either need to draw the lines in segments (one segment for every time it changes color) or you will need to use patch() to draw the lines (in which case you can configure the color of each segment by the FaceVertexCData property).
If you are using R2014a or earlier, you can draw straight lines in black but configure their EraseMode property to 'xor'. That property was seldom used and was removed as of R2014b.
Image Analyst
Image Analyst 2016 年 5 月 9 日
Do you want the grid burned into the image itself, or plotted into the overlay above the image (for example, a grid of white, clack or red lines)?

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

カテゴリ

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