How can I assign a matrix to a grid on an image?

4 ビュー (過去 30 日間)
Jake
Jake 2013 年 5 月 28 日
I would like to split a 1000x1000 pixel image into 10x10 pixel boxes to form a grid. I would then like to assign a zero to each box in the grid using the zeros function to create a matrix where each element in the matrix represents a box in the grid. In this case, there should be 10,000 boxes in the grid, or elements in the matrix. Any help, tips would be appreciated, I am a beginner. Thanks!

採用された回答

Walter Roberson
Walter Roberson 2013 年 5 月 28 日
You can do it visually using the axis grid properties. You might have to uistack() to push the graphic "below" the axes.
When you get your data coordinates from ginut(), ceil(coordinates ./ 10) would be the location you would change.

その他の回答 (1 件)

Image Analyst
Image Analyst 2013 年 5 月 28 日
How about this:
yourMatrix(:) = 0;
It has the same effect as what you said - sets every pixel to zero.
  2 件のコメント
Jake
Jake 2013 年 5 月 28 日
編集済み: Jake 2013 年 5 月 28 日
Hmm, maybe my question was unclear. My main goal is to overlay a grid onto an image. Say the grid is four boxes. Then the "linked" matrix would be
0 0
0 0
I could first define the matrix as: Matrix = zeros(2). Eventually I'd like to use ginput to click on one of the boxes in the grid and change the matrix to something like
1 0
1 1
where the boxes I clicked changed the matrix to 1 at that spot
Image Analyst
Image Analyst 2013 年 5 月 28 日
I still don't understand. Wouldn't the grid cover up rows and columns of pixels? A grid has to be one pixel wide.

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by