Create image matrix by choosing pixels interactively.

조회 수: 3 (최근 30일)
David Epstein
David Epstein 2018년 8월 31일
답변: David Epstein 2018년 9월 1일
Given a positive integer n (say n=50), I want to make an n x n white box with black boundary, and black grid lines, dividing it up into conceptual pixels. Then I want to click inside "pixels" that I select. The pixel should then turn grey (so that the grid lines remain visible), and an n x n image matrix should be created with the white "pixels" giving a 1 and the grey pixels giving 0 or 0.5 (I don't care which). I would be grateful for hints on how to do this. I tried roipoly but didn't succeed.
What I really want is the matrix, and I would be happy with any easy interactive method to create it. The whole point is that I need to see the image, while I'm creating the matrix. I'm sure I could do this, though it might take me a lot of time to figure out how without help. I'm looking for an easy way to code it.

채택된 답변

David Epstein
David Epstein 2018년 9월 1일
I solved this using a Matlab plot with ginput in a loop collecting one click each time it went through the loop. This built up the interactive image. The graphics matrix was built up at the same time, but was not used to construct the figure I was creating.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by