- ‘AspectRatio’ which is ratio of height/width of rectangle and define value as ‘1’
- ‘FixedAspectRatio’ to ensure that defined aspect ratio is fixed while interacting with drawn ROI and set its value as ‘true’
How to Select Square Section of Image Interactively (not programmatically)
23 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Darren Miller
il 12 Mag 2020
Commentato: Darren Miller
il 15 Mag 2020
I am making a MATLAB App / GUI where a user selects an image, then will need to select a square section within that image (then other stuff using just this selected section). The size and location of the square will be different for each case.
I have been looking at options such as drawrectangle ( https://www.mathworks.com/help/images/ref/drawrectangle.html ), but I don't see a way to enforce the region selected is a square.
Of course, a rectangular section could be modified by trimming off excess pixels to make it a square programmatically, but that could affect the center of the region. I was thinking about using ginput to select a center location, then defining a square size that would lie on that center location..
Does anyone have a suggestion for a better way to select a square section of an image?
0 Commenti
Risposta accettata
Payas Bahade
il 15 Mag 2020
Hi Darren,
You can use drawrectangle function and pass following name-value pairs to ensure ROI is a square:
rect = drawrectangle(app.UIAxes,'AspectRatio',1,'FixedAspectRatio',true);
Hope this helps!
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!