Create image matrix by choosing pixels interactively.

3 views (last 30 days)
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.

Accepted Answer

David Epstein
David Epstein on 1 Sep 2018
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.

More Answers (0)

Categories

Find more on Line Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!