Create image matrix by choosing pixels interactively.

8 vues (au cours des 30 derniers jours)
David Epstein
David Epstein le 31 Août 2018
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.

Réponse acceptée

David Epstein
David Epstein le 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.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by